From 86e18a95b4c14aaf23b37da2040b1a7c9cdff72c Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 17 Nov 2026 09:21:13 +0000 Subject: [PATCH 01/12] feat(studio): switch an installed app's action on or off on the action, in Studio; retire Setup's Packaged Actions A read-only app package's vendor action now carries the activation ledger's switch on the object's Actions view in Studio, and a standalone action item carries it on its page. Platform (kernel-package) actions get no switch. Setup's Packaged Actions entry and page are removed in the same change; the old URL redirects to Studio. ADR-0146 D4 gains a dated amendment, and the runtime's "turned off" sentence and the disabledActions description now point at the action in Studio; for a platform action already switched off, the sentence names the activation door instead. Co-Authored-By: Claude Claude-Session: https://claude.ai/code/session_01WGufziD6XhBNH9acXaG2Me --- .../34724-action-switch-moves-to-studio.md | 34 + content/docs/references/api/app-bundle.mdx | 10 +- content/docs/references/api/protocol.mdx | 2 +- ...ditor-per-item-paired-customize-package.md | 21 + docs/qa/platform-checklist/RUNNER.md | 27 +- .../platform-checklist/areas/api-backend.json | 14 +- .../platform-checklist/areas/automation.json | 53 +- .../areas/platform-core.json | 10 +- .../test/setup-landing-audience.pin.test.ts | 56 +- .../objectql/src/action-activation.test.ts | 33 +- packages/objectql/src/action-activation.ts | 33 +- packages/objectql/src/engine-actions.ts | 26 +- .../src/apps/setup-nav.contributions.ts | 67 +- .../apps/setup-packaged-actions-nav.test.ts | 137 ++-- .../src/apps/setup-packages-door.test.ts | 2 +- .../src/apps/translations/ar.source-hashes.ts | 1 - .../src/apps/translations/ar.ts | 1 - .../src/apps/translations/de.source-hashes.ts | 1 - .../src/apps/translations/de.ts | 1 - .../src/apps/translations/en.ts | 1 - .../apps/translations/es-ES.source-hashes.ts | 1 - .../src/apps/translations/es-ES.ts | 1 - .../src/apps/translations/fr.source-hashes.ts | 1 - .../src/apps/translations/fr.ts | 1 - .../apps/translations/ja-JP.source-hashes.ts | 1 - .../src/apps/translations/ja-JP.ts | 1 - .../src/apps/translations/ko.source-hashes.ts | 1 - .../src/apps/translations/ko.ts | 1 - .../apps/translations/pt-BR.source-hashes.ts | 1 - .../src/apps/translations/pt-BR.ts | 1 - .../src/apps/translations/ru.source-hashes.ts | 1 - .../src/apps/translations/ru.ts | 1 - .../setup-nav-dead-key-tombstone.test.ts | 11 +- .../apps/translations/zh-CN.source-hashes.ts | 1 - .../src/apps/translations/zh-CN.ts | 1 - .../translations/zh-Hant.source-hashes.ts | 1 - .../src/apps/translations/zh-Hant.ts | 1 - .../sys-metadata-activation.object.test.ts | 11 +- .../api-action-door-forward.dogfood.test.ts | 6 +- ...ion-disabled-dispatch-live.dogfood.test.ts | 2 +- .../action-activation-dispatch.test.ts | 5 +- .../src/connector-credentials-ui.ts | 4 +- packages/spec/src/api/protocol.zod.ts | 2 +- .../src/packaged-item-turned-off.test.ts | 31 +- .../types/src/packaged-item-turned-off.ts | 37 +- .../app-shell/src/console/AppContent.tsx | 22 +- ...Content.setupMetadataStudio-28578.test.tsx | 25 +- ui/packages/app-shell/src/index.ts | 6 - .../src/services/builtinComponents.tsx | 22 +- ...EditPage.actionLedgerSwitch-34724.test.tsx | 168 +++++ .../views/metadata-admin/ResourceEditPage.tsx | 77 +++ ...ckagedActionsPage.navContribution.test.tsx | 90 --- .../src/views/setup/PackagedActionsPage.tsx | 52 -- .../setup/PackagedActionsSection.test.tsx | 613 ------------------ .../views/setup/PackagedActionsSection.tsx | 502 -------------- .../src/views/setup/packagedActionLedger.ts | 242 +++++++ .../src/views/setup/packagedActions.test.ts | 149 +---- .../src/views/setup/packagedActions.ts | 207 +----- .../views/studio-design/FlowLedgerSwitch.tsx | 31 +- ...ctActionsPanel.ledgerSwitch-34724.test.tsx | 239 +++++++ .../studio-design/ObjectActionsPanel.tsx | 92 ++- .../noRetiredSetupLink-28578.test.ts | 26 +- .../setupMetadataRedirect.test.ts | 13 + .../studio-design/setupMetadataRedirect.ts | 20 + .../core/src/utils/served-object-label.ts | 3 +- ui/packages/i18n/src/namespaces/studio/en.ts | 6 + ui/packages/i18n/src/namespaces/studio/zh.ts | 5 + 67 files changed, 1355 insertions(+), 1910 deletions(-) create mode 100644 .changeset/34724-action-switch-moves-to-studio.md create mode 100644 ui/packages/app-shell/src/views/metadata-admin/ResourceEditPage.actionLedgerSwitch-34724.test.tsx delete mode 100644 ui/packages/app-shell/src/views/setup/PackagedActionsPage.navContribution.test.tsx delete mode 100644 ui/packages/app-shell/src/views/setup/PackagedActionsPage.tsx delete mode 100644 ui/packages/app-shell/src/views/setup/PackagedActionsSection.test.tsx delete mode 100644 ui/packages/app-shell/src/views/setup/PackagedActionsSection.tsx create mode 100644 ui/packages/app-shell/src/views/setup/packagedActionLedger.ts create mode 100644 ui/packages/app-shell/src/views/studio-design/ObjectActionsPanel.ledgerSwitch-34724.test.tsx diff --git a/.changeset/34724-action-switch-moves-to-studio.md b/.changeset/34724-action-switch-moves-to-studio.md new file mode 100644 index 00000000000..5a93aedd2a4 --- /dev/null +++ b/.changeset/34724-action-switch-moves-to-studio.md @@ -0,0 +1,34 @@ +--- +'@object-ui/app-shell': patch +'@object-ui/i18n': patch +'@object-ui/core': patch +'@objectstack/platform-objects': patch +'@objectstack/types': patch +'@objectstack/objectql': patch +'@objectstack/spec': patch +'@objectstack/service-automation': patch +--- + +feat(studio): an installed app's action is switched on or off on the action itself, in Studio; Setup › Packaged Actions retires (ADR-0146 D4, amended 2026-11-17) + +Clause-②: yes (narrowing: the Setup `nav_packaged_actions` entry, its `automation:packaged-actions` page and the public `PackagedActionsPage` export of `@object-ui/app-shell` retire; widening: new studio-namespace locale keys) +Metadata-protocol: none (no spec schema changes; `platform-objects` serves one fewer Setup navigation item, and one `.describe()` sentence changes) + +Before this change, the deployment's on/off switch for an installed app's actions lived on a separate Setup page, "Packaged Actions", away from where the action is read. It now sits on the action: + +- On the object's Actions view in Studio, a read-only app package's vendor action carries a "Switched on / off for this deployment" switch, the flow switch's twin. A switched-off action is marked in the list. A refusal is the server's sentence, shown verbatim; a caller the deployment's posture walls off sees the switch disabled with the reason. +- A standalone `action` item's page in Studio's "All metadata" area carries the same switch. +- The platform's own actions (any action a kernel package ships) carry no switch anywhere. When the package list cannot be read, no switch is offered. + +The doors are unchanged: the read is the `sys_metadata_activation` ledger, the write is `POST /api/v1/actions/_activation/:object/:action` with body `{ enabled }`. + +Setup › Packaged Actions is removed in the same change. A bookmark of `/apps/setup/component/automation/packaged-actions` redirects to Studio (to the package's Data pillar when the URL names `?package=`). The runtime's "turned off" sentence for a dispatched app action now points at the action in Studio, and the `disabledActions` description in `@objectstack/spec` says the same; no schema shape changes. + +**Platform actions already switched off.** The retired page also listed the platform's own actions (those a kernel package ships, such as `sys_user`'s Ban User), so a deployment may hold ledger rows that switch one off. Those rows stay in force: no boot or upgrade step turns them back on, and the activation door is unchanged. Because Studio has no switch for them, the `409 ACTION_DISABLED` sentence for a platform action now names the activation door instead of Studio. To find them on a deployment, as a platform operator: + +1. `GET /api/v1/data/sys_metadata_activation?top=1000` and keep the rows with `metadata_type: "action"` and `active: false`. If the response says `hasMore: true`, the list is incomplete; page through it before concluding. +2. `GET /api/v1/packages`: a row whose `package_id` belongs to a package with `manifest.scope` `system` or `cloud` is a switched-off platform action. + +To turn one on again: `POST /api/v1/actions/_activation//` with body `{"enabled": true}` (use `global` as `` for an action that belongs to no object). The `packagedAutomation.*` console locale keys the page read are no longer read and are left in place for a later sweep. + + diff --git a/content/docs/references/api/app-bundle.mdx b/content/docs/references/api/app-bundle.mdx index b0abc7d22ef..10e5fec2e58 100644 --- a/content/docs/references/api/app-bundle.mdx +++ b/content/docs/references/api/app-bundle.mdx @@ -99,7 +99,7 @@ const result = AppMetadataBundleResponseSchema.parse(data); | **resettable** | `boolean` | optional | Whether the item can be reset to its packaged default — true iff it is artifact-backed, i.e. there is a baseline to reset TO. | | **version** | `string \| null` | optional | ADR-0008 version token of the STORED row a save to this item compares against, at this read's scope (the environment's partition and `?package=`) and lifecycle (`?state=draft` reads the draft row, the plain read the active row). The same keyed token a save receipt's `version` serves for that row: send it back as the `If-Match` request header on `PUT /meta/:type/:name` (with `?mode=draft` for the draft) and a concurrent edit is refused 409 `METADATA_CONFLICT` instead of overwritten. `null` when no stored row is there — an item served from code or a package artifact, or from a row in another scope (a package-less row a package read falls back to) — so the next save creates one: pin it with `If-None-Match: *`. A `null` beside `editable: false` is no such invitation: that item takes no save at this address, so no pin is prescribed for it. ABSENT on the cached published-value branch and on a `?preview=draft` read, which publish no version: absence means "not published here", never "no row". Opaque — echo it verbatim, never parse it. | | **registration** | `{ state: 'registered' } \| { state: 'refused'; reason: object } \| { state: 'unregistered' }` | optional | The automation engine's verdict on this flow (see `FlowRegistrationSchema`): `registered`, or `refused` with the engine's `reason` verbatim, or `unregistered`. Present only on a `flow` read answered by a process that runs an automation service; absent otherwise, and absence means no engine judged it, never `registered`. Unlike the protection keys it is published by the cached branch too, read live and never part of the ETag, so a cached read that carries it is never answered 304; it is absent on a draft read, whose pending body no engine holds. The verdict is the answering process's engine. Beside `item`, never inside it: the item's `status` stays what its author declared. | -| **disabledActions** | `string[]` | optional | The names in `item.actions` that this deployment's activation ledger switches off (an administrator turned them off under Setup › Packaged Actions): a call to any of them is refused 409 `ACTION_DISABLED`. Present only on an `object` read answered by a process whose data engine has an activation ledger attached, and then `[]` when none of this object's actions is switched off. Absent otherwise, and absence means no ledger answered, never that nothing is switched off. Unlike the protection keys it is published by the cached branch too, read live and folded into the ETag, so a cached read revalidates to 304 only while the switched-off set is unchanged; it is absent on a draft read. The ledger is the answering process's engine's. Beside `item`, never inside it: `item.actions` is served as declared, a switched-off action included. | +| **disabledActions** | `string[]` | optional | The names in `item.actions` that this deployment's activation ledger switches off (an administrator turned them off on the action, in its package in Studio): a call to any of them is refused 409 `ACTION_DISABLED`. Present only on an `object` read answered by a process whose data engine has an activation ledger attached, and then `[]` when none of this object's actions is switched off. Absent otherwise, and absence means no ledger answered, never that nothing is switched off. Unlike the protection keys it is published by the cached branch too, read live and folded into the ETag, so a cached read revalidates to 304 only while the switched-off set is unchanged; it is absent on a draft read. The ledger is the answering process's engine's. Beside `item`, never inside it: `item.actions` is served as declared, a switched-off action included. | | **cascadeDeleteObjects** | `string[]` | optional | The objects, by name, that deleting a record of this object can also delete: every object whose relation into it cascades (a `master_detail` by default, a `lookup`, `tree` or `user` field that declares `deleteBehavior: 'cascade'`), and the objects that cascade into those in turn, each once, in the order the delete reaches them. This object itself is named only when a cascading relation leads back to it. A `restrict` or `set_null` relation removes nothing and is not named. Read from the rule the delete runs, and object-level: it never says which records or how many. Present only on an `object` read answered by a process whose data engine answers it, and then `[]` when nothing cascades. Absent otherwise, and absence means no engine answered, never that nothing cascades. Unlike the protection keys it is published by the cached branch too, read live and folded into the ETag; it is absent on a draft read. Beside `item`, never inside it: it is derived from other objects' definitions and is not authorable. | | **draftChanges** | `{ path: string[]; by: Enum<'copilot' \| 'mcp' \| 'studio' \| 'api'>; actor: string \| null; client?: object; … }[]` | optional | Per-key provenance of the pending draft: which authoring surface last changed each key path of `item`, under which actor, and when. The draft save records it: each draft save is compared with the body that save replaced (the previous draft, or the stored published row for the draft's first save; a draft of an item with no stored published row is recorded as `[]`, the whole body). A `migrate-stored` rewrite of a draft row records nothing, since it is not authoring. The entries are kept from the first recorded save until the draft is published or discarded, which remove the draft row and the entries with it; and no two entries share a path: a save replaces every entry at or under each path it changes, so the last write to change a key is the entry whose `path` is the longest prefix of that key's path, and entries under a key's path are changes inside it. The entries name which writes changed what; they are not a list of every difference from the published body (compare the two bodies for that). Served only on a `?state=draft` read that answers a stored draft row. ABSENT on the active read, the cached branch and a `?preview=draft` read, and for a draft row whose saves recorded none: absence means "not recorded", never "no changes". | @@ -123,7 +123,7 @@ const result = AppMetadataBundleResponseSchema.parse(data); | **resettable** | `boolean` | optional | Whether the item can be reset to its packaged default — true iff it is artifact-backed, i.e. there is a baseline to reset TO. | | **version** | `string \| null` | optional | ADR-0008 version token of the STORED row a save to this item compares against, at this read's scope (the environment's partition and `?package=`) and lifecycle (`?state=draft` reads the draft row, the plain read the active row). The same keyed token a save receipt's `version` serves for that row: send it back as the `If-Match` request header on `PUT /meta/:type/:name` (with `?mode=draft` for the draft) and a concurrent edit is refused 409 `METADATA_CONFLICT` instead of overwritten. `null` when no stored row is there — an item served from code or a package artifact, or from a row in another scope (a package-less row a package read falls back to) — so the next save creates one: pin it with `If-None-Match: *`. A `null` beside `editable: false` is no such invitation: that item takes no save at this address, so no pin is prescribed for it. ABSENT on the cached published-value branch and on a `?preview=draft` read, which publish no version: absence means "not published here", never "no row". Opaque — echo it verbatim, never parse it. | | **registration** | `{ state: 'registered' } \| { state: 'refused'; reason: object } \| { state: 'unregistered' }` | optional | The automation engine's verdict on this flow (see `FlowRegistrationSchema`): `registered`, or `refused` with the engine's `reason` verbatim, or `unregistered`. Present only on a `flow` read answered by a process that runs an automation service; absent otherwise, and absence means no engine judged it, never `registered`. Unlike the protection keys it is published by the cached branch too, read live and never part of the ETag, so a cached read that carries it is never answered 304; it is absent on a draft read, whose pending body no engine holds. The verdict is the answering process's engine. Beside `item`, never inside it: the item's `status` stays what its author declared. | -| **disabledActions** | `string[]` | optional | The names in `item.actions` that this deployment's activation ledger switches off (an administrator turned them off under Setup › Packaged Actions): a call to any of them is refused 409 `ACTION_DISABLED`. Present only on an `object` read answered by a process whose data engine has an activation ledger attached, and then `[]` when none of this object's actions is switched off. Absent otherwise, and absence means no ledger answered, never that nothing is switched off. Unlike the protection keys it is published by the cached branch too, read live and folded into the ETag, so a cached read revalidates to 304 only while the switched-off set is unchanged; it is absent on a draft read. The ledger is the answering process's engine's. Beside `item`, never inside it: `item.actions` is served as declared, a switched-off action included. | +| **disabledActions** | `string[]` | optional | The names in `item.actions` that this deployment's activation ledger switches off (an administrator turned them off on the action, in its package in Studio): a call to any of them is refused 409 `ACTION_DISABLED`. Present only on an `object` read answered by a process whose data engine has an activation ledger attached, and then `[]` when none of this object's actions is switched off. Absent otherwise, and absence means no ledger answered, never that nothing is switched off. Unlike the protection keys it is published by the cached branch too, read live and folded into the ETag, so a cached read revalidates to 304 only while the switched-off set is unchanged; it is absent on a draft read. The ledger is the answering process's engine's. Beside `item`, never inside it: `item.actions` is served as declared, a switched-off action included. | | **cascadeDeleteObjects** | `string[]` | optional | The objects, by name, that deleting a record of this object can also delete: every object whose relation into it cascades (a `master_detail` by default, a `lookup`, `tree` or `user` field that declares `deleteBehavior: 'cascade'`), and the objects that cascade into those in turn, each once, in the order the delete reaches them. This object itself is named only when a cascading relation leads back to it. A `restrict` or `set_null` relation removes nothing and is not named. Read from the rule the delete runs, and object-level: it never says which records or how many. Present only on an `object` read answered by a process whose data engine answers it, and then `[]` when nothing cascades. Absent otherwise, and absence means no engine answered, never that nothing cascades. Unlike the protection keys it is published by the cached branch too, read live and folded into the ETag; it is absent on a draft read. Beside `item`, never inside it: it is derived from other objects' definitions and is not authorable. | | **draftChanges** | `{ path: string[]; by: Enum<'copilot' \| 'mcp' \| 'studio' \| 'api'>; actor: string \| null; client?: object; … }[]` | optional | Per-key provenance of the pending draft: which authoring surface last changed each key path of `item`, under which actor, and when. The draft save records it: each draft save is compared with the body that save replaced (the previous draft, or the stored published row for the draft's first save; a draft of an item with no stored published row is recorded as `[]`, the whole body). A `migrate-stored` rewrite of a draft row records nothing, since it is not authoring. The entries are kept from the first recorded save until the draft is published or discarded, which remove the draft row and the entries with it; and no two entries share a path: a save replaces every entry at or under each path it changes, so the last write to change a key is the entry whose `path` is the longest prefix of that key's path, and entries under a key's path are changes inside it. The entries name which writes changed what; they are not a list of every difference from the published body (compare the two bodies for that). Served only on a `?state=draft` read that answers a stored draft row. ABSENT on the active read, the cached branch and a `?preview=draft` read, and for a draft row whose saves recorded none: absence means "not recorded", never "no changes". | @@ -147,7 +147,7 @@ const result = AppMetadataBundleResponseSchema.parse(data); | **resettable** | `boolean` | optional | Whether the item can be reset to its packaged default — true iff it is artifact-backed, i.e. there is a baseline to reset TO. | | **version** | `string \| null` | optional | ADR-0008 version token of the STORED row a save to this item compares against, at this read's scope (the environment's partition and `?package=`) and lifecycle (`?state=draft` reads the draft row, the plain read the active row). The same keyed token a save receipt's `version` serves for that row: send it back as the `If-Match` request header on `PUT /meta/:type/:name` (with `?mode=draft` for the draft) and a concurrent edit is refused 409 `METADATA_CONFLICT` instead of overwritten. `null` when no stored row is there — an item served from code or a package artifact, or from a row in another scope (a package-less row a package read falls back to) — so the next save creates one: pin it with `If-None-Match: *`. A `null` beside `editable: false` is no such invitation: that item takes no save at this address, so no pin is prescribed for it. ABSENT on the cached published-value branch and on a `?preview=draft` read, which publish no version: absence means "not published here", never "no row". Opaque — echo it verbatim, never parse it. | | **registration** | `{ state: 'registered' } \| { state: 'refused'; reason: object } \| { state: 'unregistered' }` | optional | The automation engine's verdict on this flow (see `FlowRegistrationSchema`): `registered`, or `refused` with the engine's `reason` verbatim, or `unregistered`. Present only on a `flow` read answered by a process that runs an automation service; absent otherwise, and absence means no engine judged it, never `registered`. Unlike the protection keys it is published by the cached branch too, read live and never part of the ETag, so a cached read that carries it is never answered 304; it is absent on a draft read, whose pending body no engine holds. The verdict is the answering process's engine. Beside `item`, never inside it: the item's `status` stays what its author declared. | -| **disabledActions** | `string[]` | optional | The names in `item.actions` that this deployment's activation ledger switches off (an administrator turned them off under Setup › Packaged Actions): a call to any of them is refused 409 `ACTION_DISABLED`. Present only on an `object` read answered by a process whose data engine has an activation ledger attached, and then `[]` when none of this object's actions is switched off. Absent otherwise, and absence means no ledger answered, never that nothing is switched off. Unlike the protection keys it is published by the cached branch too, read live and folded into the ETag, so a cached read revalidates to 304 only while the switched-off set is unchanged; it is absent on a draft read. The ledger is the answering process's engine's. Beside `item`, never inside it: `item.actions` is served as declared, a switched-off action included. | +| **disabledActions** | `string[]` | optional | The names in `item.actions` that this deployment's activation ledger switches off (an administrator turned them off on the action, in its package in Studio): a call to any of them is refused 409 `ACTION_DISABLED`. Present only on an `object` read answered by a process whose data engine has an activation ledger attached, and then `[]` when none of this object's actions is switched off. Absent otherwise, and absence means no ledger answered, never that nothing is switched off. Unlike the protection keys it is published by the cached branch too, read live and folded into the ETag, so a cached read revalidates to 304 only while the switched-off set is unchanged; it is absent on a draft read. The ledger is the answering process's engine's. Beside `item`, never inside it: `item.actions` is served as declared, a switched-off action included. | | **cascadeDeleteObjects** | `string[]` | optional | The objects, by name, that deleting a record of this object can also delete: every object whose relation into it cascades (a `master_detail` by default, a `lookup`, `tree` or `user` field that declares `deleteBehavior: 'cascade'`), and the objects that cascade into those in turn, each once, in the order the delete reaches them. This object itself is named only when a cascading relation leads back to it. A `restrict` or `set_null` relation removes nothing and is not named. Read from the rule the delete runs, and object-level: it never says which records or how many. Present only on an `object` read answered by a process whose data engine answers it, and then `[]` when nothing cascades. Absent otherwise, and absence means no engine answered, never that nothing cascades. Unlike the protection keys it is published by the cached branch too, read live and folded into the ETag; it is absent on a draft read. Beside `item`, never inside it: it is derived from other objects' definitions and is not authorable. | | **draftChanges** | `{ path: string[]; by: Enum<'copilot' \| 'mcp' \| 'studio' \| 'api'>; actor: string \| null; client?: object; … }[]` | optional | Per-key provenance of the pending draft: which authoring surface last changed each key path of `item`, under which actor, and when. The draft save records it: each draft save is compared with the body that save replaced (the previous draft, or the stored published row for the draft's first save; a draft of an item with no stored published row is recorded as `[]`, the whole body). A `migrate-stored` rewrite of a draft row records nothing, since it is not authoring. The entries are kept from the first recorded save until the draft is published or discarded, which remove the draft row and the entries with it; and no two entries share a path: a save replaces every entry at or under each path it changes, so the last write to change a key is the entry whose `path` is the longest prefix of that key's path, and entries under a key's path are changes inside it. The entries name which writes changed what; they are not a list of every difference from the published body (compare the two bodies for that). Served only on a `?state=draft` read that answers a stored draft row. ABSENT on the active read, the cached branch and a `?preview=draft` read, and for a draft row whose saves recorded none: absence means "not recorded", never "no changes". | @@ -171,7 +171,7 @@ const result = AppMetadataBundleResponseSchema.parse(data); | **resettable** | `boolean` | optional | Whether the item can be reset to its packaged default — true iff it is artifact-backed, i.e. there is a baseline to reset TO. | | **version** | `string \| null` | optional | ADR-0008 version token of the STORED row a save to this item compares against, at this read's scope (the environment's partition and `?package=`) and lifecycle (`?state=draft` reads the draft row, the plain read the active row). The same keyed token a save receipt's `version` serves for that row: send it back as the `If-Match` request header on `PUT /meta/:type/:name` (with `?mode=draft` for the draft) and a concurrent edit is refused 409 `METADATA_CONFLICT` instead of overwritten. `null` when no stored row is there — an item served from code or a package artifact, or from a row in another scope (a package-less row a package read falls back to) — so the next save creates one: pin it with `If-None-Match: *`. A `null` beside `editable: false` is no such invitation: that item takes no save at this address, so no pin is prescribed for it. ABSENT on the cached published-value branch and on a `?preview=draft` read, which publish no version: absence means "not published here", never "no row". Opaque — echo it verbatim, never parse it. | | **registration** | `{ state: 'registered' } \| { state: 'refused'; reason: object } \| { state: 'unregistered' }` | optional | The automation engine's verdict on this flow (see `FlowRegistrationSchema`): `registered`, or `refused` with the engine's `reason` verbatim, or `unregistered`. Present only on a `flow` read answered by a process that runs an automation service; absent otherwise, and absence means no engine judged it, never `registered`. Unlike the protection keys it is published by the cached branch too, read live and never part of the ETag, so a cached read that carries it is never answered 304; it is absent on a draft read, whose pending body no engine holds. The verdict is the answering process's engine. Beside `item`, never inside it: the item's `status` stays what its author declared. | -| **disabledActions** | `string[]` | optional | The names in `item.actions` that this deployment's activation ledger switches off (an administrator turned them off under Setup › Packaged Actions): a call to any of them is refused 409 `ACTION_DISABLED`. Present only on an `object` read answered by a process whose data engine has an activation ledger attached, and then `[]` when none of this object's actions is switched off. Absent otherwise, and absence means no ledger answered, never that nothing is switched off. Unlike the protection keys it is published by the cached branch too, read live and folded into the ETag, so a cached read revalidates to 304 only while the switched-off set is unchanged; it is absent on a draft read. The ledger is the answering process's engine's. Beside `item`, never inside it: `item.actions` is served as declared, a switched-off action included. | +| **disabledActions** | `string[]` | optional | The names in `item.actions` that this deployment's activation ledger switches off (an administrator turned them off on the action, in its package in Studio): a call to any of them is refused 409 `ACTION_DISABLED`. Present only on an `object` read answered by a process whose data engine has an activation ledger attached, and then `[]` when none of this object's actions is switched off. Absent otherwise, and absence means no ledger answered, never that nothing is switched off. Unlike the protection keys it is published by the cached branch too, read live and folded into the ETag, so a cached read revalidates to 304 only while the switched-off set is unchanged; it is absent on a draft read. The ledger is the answering process's engine's. Beside `item`, never inside it: `item.actions` is served as declared, a switched-off action included. | | **cascadeDeleteObjects** | `string[]` | optional | The objects, by name, that deleting a record of this object can also delete: every object whose relation into it cascades (a `master_detail` by default, a `lookup`, `tree` or `user` field that declares `deleteBehavior: 'cascade'`), and the objects that cascade into those in turn, each once, in the order the delete reaches them. This object itself is named only when a cascading relation leads back to it. A `restrict` or `set_null` relation removes nothing and is not named. Read from the rule the delete runs, and object-level: it never says which records or how many. Present only on an `object` read answered by a process whose data engine answers it, and then `[]` when nothing cascades. Absent otherwise, and absence means no engine answered, never that nothing cascades. Unlike the protection keys it is published by the cached branch too, read live and folded into the ETag; it is absent on a draft read. Beside `item`, never inside it: it is derived from other objects' definitions and is not authorable. | | **draftChanges** | `{ path: string[]; by: Enum<'copilot' \| 'mcp' \| 'studio' \| 'api'>; actor: string \| null; client?: object; … }[]` | optional | Per-key provenance of the pending draft: which authoring surface last changed each key path of `item`, under which actor, and when. The draft save records it: each draft save is compared with the body that save replaced (the previous draft, or the stored published row for the draft's first save; a draft of an item with no stored published row is recorded as `[]`, the whole body). A `migrate-stored` rewrite of a draft row records nothing, since it is not authoring. The entries are kept from the first recorded save until the draft is published or discarded, which remove the draft row and the entries with it; and no two entries share a path: a save replaces every entry at or under each path it changes, so the last write to change a key is the entry whose `path` is the longest prefix of that key's path, and entries under a key's path are changes inside it. The entries name which writes changed what; they are not a list of every difference from the published body (compare the two bodies for that). Served only on a `?state=draft` read that answers a stored draft row. ABSENT on the active read, the cached branch and a `?preview=draft` read, and for a draft row whose saves recorded none: absence means "not recorded", never "no changes". | @@ -195,7 +195,7 @@ const result = AppMetadataBundleResponseSchema.parse(data); | **resettable** | `boolean` | optional | Whether the item can be reset to its packaged default — true iff it is artifact-backed, i.e. there is a baseline to reset TO. | | **version** | `string \| null` | optional | ADR-0008 version token of the STORED row a save to this item compares against, at this read's scope (the environment's partition and `?package=`) and lifecycle (`?state=draft` reads the draft row, the plain read the active row). The same keyed token a save receipt's `version` serves for that row: send it back as the `If-Match` request header on `PUT /meta/:type/:name` (with `?mode=draft` for the draft) and a concurrent edit is refused 409 `METADATA_CONFLICT` instead of overwritten. `null` when no stored row is there — an item served from code or a package artifact, or from a row in another scope (a package-less row a package read falls back to) — so the next save creates one: pin it with `If-None-Match: *`. A `null` beside `editable: false` is no such invitation: that item takes no save at this address, so no pin is prescribed for it. ABSENT on the cached published-value branch and on a `?preview=draft` read, which publish no version: absence means "not published here", never "no row". Opaque — echo it verbatim, never parse it. | | **registration** | `{ state: 'registered' } \| { state: 'refused'; reason: object } \| { state: 'unregistered' }` | optional | The automation engine's verdict on this flow (see `FlowRegistrationSchema`): `registered`, or `refused` with the engine's `reason` verbatim, or `unregistered`. Present only on a `flow` read answered by a process that runs an automation service; absent otherwise, and absence means no engine judged it, never `registered`. Unlike the protection keys it is published by the cached branch too, read live and never part of the ETag, so a cached read that carries it is never answered 304; it is absent on a draft read, whose pending body no engine holds. The verdict is the answering process's engine. Beside `item`, never inside it: the item's `status` stays what its author declared. | -| **disabledActions** | `string[]` | optional | The names in `item.actions` that this deployment's activation ledger switches off (an administrator turned them off under Setup › Packaged Actions): a call to any of them is refused 409 `ACTION_DISABLED`. Present only on an `object` read answered by a process whose data engine has an activation ledger attached, and then `[]` when none of this object's actions is switched off. Absent otherwise, and absence means no ledger answered, never that nothing is switched off. Unlike the protection keys it is published by the cached branch too, read live and folded into the ETag, so a cached read revalidates to 304 only while the switched-off set is unchanged; it is absent on a draft read. The ledger is the answering process's engine's. Beside `item`, never inside it: `item.actions` is served as declared, a switched-off action included. | +| **disabledActions** | `string[]` | optional | The names in `item.actions` that this deployment's activation ledger switches off (an administrator turned them off on the action, in its package in Studio): a call to any of them is refused 409 `ACTION_DISABLED`. Present only on an `object` read answered by a process whose data engine has an activation ledger attached, and then `[]` when none of this object's actions is switched off. Absent otherwise, and absence means no ledger answered, never that nothing is switched off. Unlike the protection keys it is published by the cached branch too, read live and folded into the ETag, so a cached read revalidates to 304 only while the switched-off set is unchanged; it is absent on a draft read. The ledger is the answering process's engine's. Beside `item`, never inside it: `item.actions` is served as declared, a switched-off action included. | | **cascadeDeleteObjects** | `string[]` | optional | The objects, by name, that deleting a record of this object can also delete: every object whose relation into it cascades (a `master_detail` by default, a `lookup`, `tree` or `user` field that declares `deleteBehavior: 'cascade'`), and the objects that cascade into those in turn, each once, in the order the delete reaches them. This object itself is named only when a cascading relation leads back to it. A `restrict` or `set_null` relation removes nothing and is not named. Read from the rule the delete runs, and object-level: it never says which records or how many. Present only on an `object` read answered by a process whose data engine answers it, and then `[]` when nothing cascades. Absent otherwise, and absence means no engine answered, never that nothing cascades. Unlike the protection keys it is published by the cached branch too, read live and folded into the ETag; it is absent on a draft read. Beside `item`, never inside it: it is derived from other objects' definitions and is not authorable. | | **draftChanges** | `{ path: string[]; by: Enum<'copilot' \| 'mcp' \| 'studio' \| 'api'>; actor: string \| null; client?: object; … }[]` | optional | Per-key provenance of the pending draft: which authoring surface last changed each key path of `item`, under which actor, and when. The draft save records it: each draft save is compared with the body that save replaced (the previous draft, or the stored published row for the draft's first save; a draft of an item with no stored published row is recorded as `[]`, the whole body). A `migrate-stored` rewrite of a draft row records nothing, since it is not authoring. The entries are kept from the first recorded save until the draft is published or discarded, which remove the draft row and the entries with it; and no two entries share a path: a save replaces every entry at or under each path it changes, so the last write to change a key is the entry whose `path` is the longest prefix of that key's path, and entries under a key's path are changes inside it. The entries name which writes changed what; they are not a list of every difference from the published body (compare the two bodies for that). Served only on a `?state=draft` read that answers a stored draft row. ABSENT on the active read, the cached branch and a `?preview=draft` read, and for a draft row whose saves recorded none: absence means "not recorded", never "no changes". | diff --git a/content/docs/references/api/protocol.mdx b/content/docs/references/api/protocol.mdx index 4027b6a360b..63c016c2573 100644 --- a/content/docs/references/api/protocol.mdx +++ b/content/docs/references/api/protocol.mdx @@ -1530,7 +1530,7 @@ This schema accepts one of the following structures: | **resettable** | `boolean` | optional | Whether the item can be reset to its packaged default — true iff it is artifact-backed, i.e. there is a baseline to reset TO. | | **version** | `string \| null` | optional | ADR-0008 version token of the STORED row a save to this item compares against, at this read's scope (the environment's partition and `?package=`) and lifecycle (`?state=draft` reads the draft row, the plain read the active row). The same keyed token a save receipt's `version` serves for that row: send it back as the `If-Match` request header on `PUT /meta/:type/:name` (with `?mode=draft` for the draft) and a concurrent edit is refused 409 `METADATA_CONFLICT` instead of overwritten. `null` when no stored row is there — an item served from code or a package artifact, or from a row in another scope (a package-less row a package read falls back to) — so the next save creates one: pin it with `If-None-Match: *`. A `null` beside `editable: false` is no such invitation: that item takes no save at this address, so no pin is prescribed for it. ABSENT on the cached published-value branch and on a `?preview=draft` read, which publish no version: absence means "not published here", never "no row". Opaque — echo it verbatim, never parse it. | | **registration** | `{ state: 'registered' } \| { state: 'refused'; reason: object } \| { state: 'unregistered' }` | optional | The automation engine's verdict on this flow (see `FlowRegistrationSchema`): `registered`, or `refused` with the engine's `reason` verbatim, or `unregistered`. Present only on a `flow` read answered by a process that runs an automation service; absent otherwise, and absence means no engine judged it, never `registered`. Unlike the protection keys it is published by the cached branch too, read live and never part of the ETag, so a cached read that carries it is never answered 304; it is absent on a draft read, whose pending body no engine holds. The verdict is the answering process's engine. Beside `item`, never inside it: the item's `status` stays what its author declared. | -| **disabledActions** | `string[]` | optional | The names in `item.actions` that this deployment's activation ledger switches off (an administrator turned them off under Setup › Packaged Actions): a call to any of them is refused 409 `ACTION_DISABLED`. Present only on an `object` read answered by a process whose data engine has an activation ledger attached, and then `[]` when none of this object's actions is switched off. Absent otherwise, and absence means no ledger answered, never that nothing is switched off. Unlike the protection keys it is published by the cached branch too, read live and folded into the ETag, so a cached read revalidates to 304 only while the switched-off set is unchanged; it is absent on a draft read. The ledger is the answering process's engine's. Beside `item`, never inside it: `item.actions` is served as declared, a switched-off action included. | +| **disabledActions** | `string[]` | optional | The names in `item.actions` that this deployment's activation ledger switches off (an administrator turned them off on the action, in its package in Studio): a call to any of them is refused 409 `ACTION_DISABLED`. Present only on an `object` read answered by a process whose data engine has an activation ledger attached, and then `[]` when none of this object's actions is switched off. Absent otherwise, and absence means no ledger answered, never that nothing is switched off. Unlike the protection keys it is published by the cached branch too, read live and folded into the ETag, so a cached read revalidates to 304 only while the switched-off set is unchanged; it is absent on a draft read. The ledger is the answering process's engine's. Beside `item`, never inside it: `item.actions` is served as declared, a switched-off action included. | | **cascadeDeleteObjects** | `string[]` | optional | The objects, by name, that deleting a record of this object can also delete: every object whose relation into it cascades (a `master_detail` by default, a `lookup`, `tree` or `user` field that declares `deleteBehavior: 'cascade'`), and the objects that cascade into those in turn, each once, in the order the delete reaches them. This object itself is named only when a cascading relation leads back to it. A `restrict` or `set_null` relation removes nothing and is not named. Read from the rule the delete runs, and object-level: it never says which records or how many. Present only on an `object` read answered by a process whose data engine answers it, and then `[]` when nothing cascades. Absent otherwise, and absence means no engine answered, never that nothing cascades. Unlike the protection keys it is published by the cached branch too, read live and folded into the ETag; it is absent on a draft read. Beside `item`, never inside it: it is derived from other objects' definitions and is not authorable. | | **draftChanges** | `{ path: string[]; by: Enum<'copilot' \| 'mcp' \| 'studio' \| 'api'>; actor: string \| null; client?: object; … }[]` | optional | Per-key provenance of the pending draft: which authoring surface last changed each key path of `item`, under which actor, and when. The draft save records it: each draft save is compared with the body that save replaced (the previous draft, or the stored published row for the draft's first save; a draft of an item with no stored published row is recorded as `[]`, the whole body). A `migrate-stored` rewrite of a draft row records nothing, since it is not authoring. The entries are kept from the first recorded save until the draft is published or discarded, which remove the draft row and the entries with it; and no two entries share a path: a save replaces every entry at or under each path it changes, so the last write to change a key is the entry whose `path` is the longest prefix of that key's path, and entries under a key's path are changes inside it. The entries name which writes changed what; they are not a list of every difference from the published body (compare the two bodies for that). Served only on a `?state=draft` read that answers a stored draft row. ABSENT on the active read, the cached branch and a `?preview=draft` read, and for a draft row whose saves recorded none: absence means "not recorded", never "no changes". | diff --git a/docs/adr/0146-studio-designs-setup-administers-one-editor-per-item-paired-customize-package.md b/docs/adr/0146-studio-designs-setup-administers-one-editor-per-item-paired-customize-package.md index e8f3a9409e8..4407cc054da 100644 --- a/docs/adr/0146-studio-designs-setup-administers-one-editor-per-item-paired-customize-package.md +++ b/docs/adr/0146-studio-designs-setup-administers-one-editor-per-item-paired-customize-package.md @@ -450,6 +450,27 @@ Fork D), not one of the §9 walls. This record moves the switch to where the ite open; it is decided. - **The action ledger switch is out of this epic** (#27842, #27504; 「四个小问题 同意」): `action` keeps ADR-0126 §8's disable leg where it is. +- **Amended 2026-11-17 — the action switch moves onto the action in Studio; Setup › Packaged Actions retires** + ([#34724](https://github.com/objectstack-ai/objectstack/issues/34724), child of epic + [#34571](https://github.com/objectstack-ai/objectstack/issues/34571); maintainer, verbatim: + 「打包动作不是应该在 studio 对应的软件包中自定义吗」, and on platform actions getting no switch, 「同意,立卡」). + The bullet above is superseded: in Studio, on a **read-only app package**, each vendor action carries the activation + ledger's switch — on the object's Actions view for an action embedded in the object, on the item's page in the "All + metadata" area for a standalone `action` item — with the flow switch's control, words ("on / off for this + deployment"), pre-judged gate and verbatim refusals (the first two bullets of this decision, unchanged). The doors + are the ones Setup's page used and are unchanged: the read is the `sys_metadata_activation` list (rows with + `metadata_type: 'action'`, absence meaning active), the write `POST /api/v1/actions/_activation/:object/:action` + (objectstack#12348), its gate the same `refuseUngrantedActivationWrite`. **The platform's own actions** (those a + kernel package ships, on `sys_user`, `sys_api_key`, `sys_sso_provider` …) **carry no switch anywhere** in the + console, and the server door is not changed. A row that already switches a platform action off stays in force: + no boot or upgrade step re-enables it (maintainer ruling + [6944409840](https://github.com/objectstack-ai/objectstack/issues/34724#issuecomment-6944409840), on the + measurement [6943920659](https://github.com/objectstack-ai/objectstack/issues/34724#issuecomment-6943920659)). + Turning one on again is the activation door's `{ enabled: true }`, and the `ACTION_DISABLED` sentence for a + platform action names that door rather than Studio. Setup's `nav_packaged_actions` entry and its + `automation:packaged-actions` page retire in the same change as the switch, so no window is left without one; a + bookmark of the page opens Studio. Action-clone stays unchartered (ADR-0126 §8 item 2): ⛔ no "new similar" for an + action, and a customer's own button stays a new action in `.custom` ([D9](#d9)). Maintainer, verbatim (2026-10-30): 「打包自动化开关,这个就很奇怪,正常的操作我应该是在studio中进入 hotcrm app,选中一个流程,点禁用或者复制更符合逻辑吧?」 diff --git a/docs/qa/platform-checklist/RUNNER.md b/docs/qa/platform-checklist/RUNNER.md index 54cbecf8d2d..02eb71ba88e 100644 --- a/docs/qa/platform-checklist/RUNNER.md +++ b/docs/qa/platform-checklist/RUNNER.md @@ -552,22 +552,21 @@ contradicts it, and correct it here when it does. bearer seam. So a session driven with the localStorage token alone gets **401 `AUTH_REQUIRED`** from `POST /api/v1/storage/upload/presigned` while `GET /auth/get-session` on the same page returns 200 — a convincing fake "avatar - upload is broken". The Setup app's **Packaged Actions** page (component ref - `automation:packaged-actions`) is built the same way: its `GET /api/v1/meta/object` - and `GET /api/v1/data/sys_metadata_activation` loads and its + upload is broken". Studio's packaged-action switch (`action-ledger-switch`, on a + read-only app's vendor action) is built the same way: its + `GET /api/v1/data/sys_metadata_activation` load and its `POST /api/v1/actions/_activation//` toggle are bare `fetch`es with `credentials: 'include'` and no `Authorization` header - (`ui/packages/app-shell/src/views/setup/PackagedActionsSection.tsx`), so a token-only - session should expect a load failure ending `HTTP 401` (`object metadata HTTP 401` or - `activation ledger HTTP 401`) in the page's `role="alert"` box instead of the action - list. That is read from source; QA run #27409 measured the shape on the Packaged - Automation page (`automation:packaged`), which retired with ADR-0146 D11: a bookmark of - `/apps//component/automation/packaged` now opens Studio's Automations pillar - (`packagedAutomationStudioPath`, - `ui/packages/app-shell/src/views/studio-design/setupMetadataRedirect.ts`), where a - packaged flow's switch and its New similar are. ⛔ Do not drive any storage/upload - surface or the Packaged Actions page from an injected token: **sign in through the - form** so both halves exist. + (`ui/packages/app-shell/src/views/setup/packagedActionLedger.ts`), so a token-only + session should expect no switch and a `role="alert"` line ending + `activation ledger HTTP 401` instead. That is read from source; QA run #27409 measured + the shape on the Packaged Automation page (`automation:packaged`), which retired with + ADR-0146 D11, and Setup's Packaged Actions page (`automation:packaged-actions`) retired + with objectstack#34724: a bookmark of either now opens Studio + (`packagedAutomationStudioPath` / `packagedActionsStudioPath`, + `ui/packages/app-shell/src/views/studio-design/setupMetadataRedirect.ts`), where each + packaged item's switch is. ⛔ Do not drive any storage/upload surface or the action + switch from an injected token: **sign in through the form** so both halves exist. - **A stock showcase boot refuses self-registration — no item can mint a member by "fresh sign-up".** The showcase declares no `auth.audience`, so its posture is the diff --git a/docs/qa/platform-checklist/areas/api-backend.json b/docs/qa/platform-checklist/areas/api-backend.json index b14d9b2b1ca..cdee8512e20 100644 --- a/docs/qa/platform-checklist/areas/api-backend.json +++ b/docs/qa/platform-checklist/areas/api-backend.json @@ -1727,7 +1727,7 @@ "title": "A disabled packaged action is refused 409 ACTION_DISABLED at BOTH dispatch doors — after the capability gate (a 403 is never an oracle for the switch), before the param contract and the record load, durable across restart", "since": "v17", "status": "active", - "revision": 13, + "revision": 14, "priority": "P0", "surface": "api", "personas": [ @@ -1759,9 +1759,9 @@ ], "acceptance": [ { - "clause": "the REST door refuses a disabled packaged action 409 ACTION_DISABLED and dispatches NOTHING: status 409, code ACTION_DISABLED (registered in the ADR-0112 ledger, error-code-ledger.zod.ts), message = the engine's own describeDisabledAction sentence, written for the end user: it says the action is turned off for this deployment and that an administrator can turn it on again under Setup › Packaged Actions, and names no system table and no ADR (the engine's log line carries those) — and no side effect lands (mark_done's declared done/progress write never ran)", + "clause": "the REST door refuses a disabled packaged action 409 ACTION_DISABLED and dispatches NOTHING: status 409, code ACTION_DISABLED (registered in the ADR-0112 ledger, error-code-ledger.zod.ts), message = the engine's own describeDisabledAction sentence, written for the end user: it says the action is turned off for this deployment and that an administrator can turn it on again on the action in its package in Studio, and names no system table and no ADR (the engine's log line carries those) — and no side effect lands (mark_done's declared done/progress write never ran)", "oracle": "api", - "verify": "step-3 trace: 409 + code ACTION_DISABLED + the disabled-action sentence; follow-up reads show no task mutated. packaged-action-disabled-dispatch-live.dogfood.test.ts scores it over HTTP: the exact code, the sentence (first sentence \"This action is turned off for this deployment.\", the Setup › Packaged Actions remedy, and no ledger table or ADR in it), and the real task re-read with done, progress and updated_at unchanged. packaged-activation-ledger-reach.dogfood.test.ts still asserts 409 and the code ACTION_DISABLED only", + "verify": "step-3 trace: 409 + code ACTION_DISABLED + the disabled-action sentence; follow-up reads show no task mutated. packaged-action-disabled-dispatch-live.dogfood.test.ts scores it over HTTP: the exact code, the sentence (first sentence \"This action is turned off for this deployment.\", the remedy that sends the reader to the action in its package in Studio, and no ledger table or ADR in it), and the real task re-read with done, progress and updated_at unchanged. packaged-activation-ledger-reach.dogfood.test.ts still asserts 409 and the code ACTION_DISABLED only", "evidence": "the trace + the control re-reads" }, { @@ -1797,7 +1797,7 @@ { "clause": "a disabled `type: flow` action is refused by its OWN switch, ahead of the type branch — the refusal is 409 ACTION_DISABLED on the action's own route (POST /api/v1/actions/showcase_task/showcase_bulk_reassign) with the turned-off sentence of acceptance[0], which names no action (describeDisabled ignores the name, packages/objectql/src/action-activation.ts), independent of anything the target flow's own ledger row says, and the target flow is left untouched", "oracle": "api", - "verify": "step-8 on /actions/showcase_task/showcase_bulk_reassign: status 409, body.error.code ACTION_DISABLED and body.error.message the turned-off sentence (first sentence \"This action is turned off for this deployment.\", the Setup › Packaged Actions remedy). Do not look for the action's name in it: the sentence names none, and the live pin's expectDisabledSentence ignores the name too. The automation service is never consulted for the run, so showcase_reassign_wizard records no run from it", + "verify": "step-8 on /actions/showcase_task/showcase_bulk_reassign: status 409, body.error.code ACTION_DISABLED and body.error.message the turned-off sentence (first sentence \"This action is turned off for this deployment.\", the remedy that sends the reader to the action in its package in Studio). Do not look for the action's name in it: the sentence names none, and the live pin's expectDisabledSentence ignores the name too. The automation service is never consulted for the run, so showcase_reassign_wizard records no run from it", "evidence": "the trace" } ], @@ -1910,6 +1910,12 @@ "date": "2026-11-02", "change": "The producer now names the live page: describeTurnedOffPackagedItem('action') (@objectstack/types) tells the reader an administrator can turn the action on again under Setup › Packaged Actions (nav_packaged_actions), not the retired Setup › Packaged automation page. acceptance[0] (clause and verify) and acceptance[6] (verify) re-point their remedy phrase to Setup › Packaged Actions, as fixtures.knownGaps[2] said they would, and that TRANSITIONAL entry is retired. The doors, the 409, the code and every ordering leg are unchanged; only the quoted remedy moved, and the live pin (packaged-action-disabled-dispatch-live.dogfood.test.ts expectDisabledSentence) asserts the same phrase", "ref": "#29374" + }, + { + "revision": 14, + "date": "2026-11-17", + "change": "Setup › Packaged Actions retired (the ADR-0146 D4 amendment of 2026-11-17): a packaged action's switch is on the action, in its package in Studio. describeTurnedOffPackagedItem('action') now tells the reader an administrator can turn it on again on the action in its package in Studio. acceptance[0] (clause and verify) and acceptance[6] (verify) re-point their remedy phrase; steps, doors and codes are unchanged.", + "ref": "#34724" } ] }, diff --git a/docs/qa/platform-checklist/areas/automation.json b/docs/qa/platform-checklist/areas/automation.json index 3c957b7d744..9a6f3d89890 100644 --- a/docs/qa/platform-checklist/areas/automation.json +++ b/docs/qa/platform-checklist/areas/automation.json @@ -2364,10 +2364,10 @@ }, { "id": "automation.setup-packaged-automation-board", - "title": "The packaged-automation doors after ADR-0146 D4/D11: Setup nav serves Packaged actions (the retired flows page's bookmark lands in Studio), Studio's Automations pillar lists the packaged flows, its ledger switch persists, New similar is offered on flows only, no lineage surface, server refusals verbatim in role=alert", + "title": "The packaged-automation doors after ADR-0146 D4 (amended 2026-11-17)/D11: Setup nav serves neither retired page (both bookmarks land in Studio), Studio's Automations pillar lists the packaged flows, its ledger switch persists, a read-only app's vendor actions carry the same switch in the Data pillar and platform actions none, New similar is offered on flows only, no lineage surface, server refusals verbatim in role=alert", "since": "v17", "status": "active", - "revision": 13, + "revision": 14, "priority": "P1", "surface": "browser", "personas": [ @@ -2378,34 +2378,34 @@ "app": "showcase", "requires": [ "a console bundle built from this checkout's ui/ tree with `pnpm console:build` (both doors are ui/ code — a packages/console/dist older than the tree tests last week's pages: RUNNER.md's stale-console-bundle trap)", - "the packaged showcase flows (com.example.showcase, read-only in Studio) and at least one packaged action for the Packaged actions page", + "the packaged showcase flows (com.example.showcase, read-only in Studio) and at least one packaged action on a showcase object (the Data pillar's Actions view draws its switch)", "the stock subflow pair showcase_task_done_notify_owner → showcase_notify_owner (drives the 409 refusal-rendering clause)", "the read-only base's customization pair com.example.showcase.custom, which New similar targets when no package is sent: the clone door ensures it through ADR-0146 D3's door (D4)" ], "knownGaps": [ - "TRANSITION (ADR-0146 D4/D11, #28785 then #28818): the Setup page this item was authored against (PackagedAutomationPage.tsx, ref 'automation:packaged', nav_packaged_automation) is retired. Its flows half is Studio's Automations pillar on the read-only package (the FlowLedgerSwitch header switch and FlowItemMoreMenu's New similar); its actions half is Setup › Packaged actions (PackagedActionsPage.tsx, ref 'automation:packaged-actions', nav_packaged_actions). The retired page's bookmark /apps/APP/component/automation/packaged is a static route (PackagedAutomationRedirect, AppContent.tsx) that opens /studio/PKG/automations when ?package= names one and /studio/~all/metadata/flow otherwise (packagedAutomationStudioPath, setupMetadataRedirect.ts). Re-pointed from QA run #29124 (W4-L1, 7fa9873f), which drove every clause on these replacements", - "REPO OWNERSHIP (ADR-0054) still splits the nav clause: the PAGES — markup, testids, dialogs, refusal rendering — are the ui/ tree's (Studio: ui/packages/app-shell/src/views/studio-design/; Setup › Packaged actions: views/setup/PackagedActionsPage.tsx + PackagedActionsSection.tsx); the Setup NAV METADATA that reaches the actions page is packages/platform-objects/src/apps/setup-nav.contributions.ts (nav_packaged_actions). Each side pins its own half (setup-packaged-actions-nav.test.ts; PackagedActionsPage.navContribution.test.tsx), and only the live sidebar click observes the seam between them", + "TRANSITION (ADR-0146 D4/D11, #28785 then #28818): the Setup page this item was authored against (PackagedAutomationPage.tsx, ref 'automation:packaged', nav_packaged_automation) is retired. Its flows half is Studio's Automations pillar on the read-only package (the FlowLedgerSwitch header switch and FlowItemMoreMenu's New similar); its actions half is Setup › Packaged actions (PackagedActionsPage.tsx, ref 'automation:packaged-actions', nav_packaged_actions). The retired page's bookmark /apps/APP/component/automation/packaged is a static route (PackagedAutomationRedirect, AppContent.tsx) that opens /studio/PKG/automations when ?package= names one and /studio/~all/metadata/flow otherwise (packagedAutomationStudioPath, setupMetadataRedirect.ts). Re-pointed from QA run #29124 (W4-L1, 7fa9873f), which drove every clause on these replacements. Second TRANSITION (objectstack#34724, the ADR-0146 D4 amendment of 2026-11-17): the actions half retired too. Setup › Packaged actions (PackagedActionsPage.tsx, ref 'automation:packaged-actions', nav_packaged_actions) is gone; a read-only app's vendor action carries the ledger switch (action-ledger-switch) on its object's Actions view in Studio's Data pillar (ObjectActionsPanel.tsx) and, for a standalone action item, on its page in the All metadata area (ResourceEditPage.tsx); a platform (kernel-package) action carries none anywhere. The bookmark /apps/APP/component/automation/packaged-actions is a static route (PackagedActionsRedirect, AppContent.tsx) that opens /studio/PKG/data when ?package= names one and /studio (the landing) otherwise (packagedActionsStudioPath, setupMetadataRedirect.ts). No QA run has driven the actions half in Studio yet", + "REPO OWNERSHIP (ADR-0054) still splits the nav clause: the PAGES — markup, testids, dialogs, refusal rendering — are the ui/ tree's (ui/packages/app-shell/src/views/studio-design/, and the two bookmark redirects in console/AppContent.tsx); the Setup NAV METADATA is packages/platform-objects/src/apps/setup-nav.contributions.ts, which since objectstack#34724 ships no packaged-automation entry at all. Each side pins its own half (setup-packaged-actions-nav.test.ts pins both absences; AppContent.setupMetadataStudio-28578.test.tsx pins both bookmarks), and only the live served body observes the seam between them", "MEMBER POSTURE MEASURED, NOT ADJUDICATED (QA runs #23163 at 36b2889c, #26468 at 756220c4, #29124 at 7fa9873f): a plain member cannot open the Setup app, and #29124 measured that Studio refuses the member too; the member's read of sys_metadata_activation answers 403 while GET /api/v1/automation/_status and GET /api/v1/meta/action stay open. That is the opposite of the 'Reads stay open' note in packages/platform-objects/src/system/sys-metadata-activation.object.ts. The maintainer question acceptance[7] flags is still open. While the member reaches neither door, acceptance[5]'s member cell is scored over the API (the toggle door's 403 body): record that it was" ] }, "steps": [ "boot the showcase on its own port and DB (dogfood §0, OS_PORT exported); build/serve the pinned console; sign in as the dev admin", - "nav probe: GET /api/v1/meta/app?id=setup and search the served navigation for the type:'component' item with componentRef 'automation:packaged-actions' (and confirm no item names 'automation:packaged'); then click the entry in the rendered Setup sidebar. Then type the retired page's bookmark /_console/apps/com.objectstack.setup/component/automation/packaged and record where it lands (no ?package= → /_console/studio/~all/metadata/flow), and once more with ?package=com.example.showcase (→ /_console/studio/com.example.showcase/automations, the query kept)", + "nav probe: GET /api/v1/meta/app?id=setup and confirm no served item names componentRef 'automation:packaged-actions' or 'automation:packaged' (nor the ids nav_packaged_actions / nav_packaged_automation), and that the rendered Setup sidebar has no Packaged actions entry. Then type each retired bookmark and record where it lands: /_console/apps/com.objectstack.setup/component/automation/packaged (no ?package= → /_console/studio/~all/metadata/flow; with ?package=com.example.showcase → /_console/studio/com.example.showcase/automations, the query kept) and /_console/apps/com.objectstack.setup/component/automation/packaged-actions (no ?package= → /_console/studio; with ?package=com.example.showcase → /_console/studio/com.example.showcase/data, the query kept)", "open Studio on the read-only package: /_console/studio/com.example.showcase/automations; screenshot the rail settled", "inventory: compare the rail's flows against GET /api/v1/automation/_status (the runtime list whose rows carry the ledger flag) and GET /api/v1/meta/flow (the items whose _packageId is com.example.showcase). Open a flow (the URL gains ?surface=flow:NAME, studioPillarItemPath in metadataArea.ts) and read the header switch data-testid auto-ledger-switch as two facts: aria-checked is the ledger flag of that flow's _status row, and data-reading says whether the flow RUNS ('on' — 'Switched on for this deployment'; 'not-running' — 'Switched on for this deployment, not running here', with the platform's reason in auto-ledger-not-running-reason; 'off' — 'Switched off for this deployment'; engine.studio.auto.ledger.*). The readings come from objectui packagedFlows.ts activationReading, the same rule the retired page used. Expect showcase_approver_bindings (authored status: 'obsolete') off, and on a default boot (OS_AUTOMATION_SCHEDULED_WORK_ENABLED unset) showcase_scheduled_digest and showcase_task_due_reminder not-running with unboundCause 'deployment_policy'. Reconcile against _status, not against counts: QA run #29124 read 32 flows on both the rail and _status", "toggle: on showcase_urgent_task_alert flip auto-ledger-switch OFF (POST /api/v1/automation/showcase_urgent_task_alert/toggle); reload the page fully and re-open the flow; record the switch state and the sys_metadata_activation row (metadata_type 'flow', name showcase_urgent_task_alert, active false); flip it back ON", "New similar: on an open packaged flow open the ⋯ menu (auto-item-more) → New similar (auto-item-new-similar). The dialog (auto-new-similar-dialog) opens PREFILLED with NAME_copy and 'LABEL (copy)', both editable and submit enabled (FlowItemMoreMenu.tsx openNewSimilar), so clear each field first — then try submitting with name empty, label empty, then name 'Bad-Name!' + a label; record what renders; then make a legal copy and record the landing strip (auto-new-similar-strip, with the door's notice in auto-new-similar-notice) and where the copy opened; DELETE the copy via the API afterwards", - "Packaged actions: open Setup › Packaged actions (the sidebar entry of steps[1]) and screenshot the section (data-testid packaged-actions-section) and its rows", + "Packaged actions: open /_console/studio/com.example.showcase/data, select a showcase object that declares actions, open its Actions view and select a vendor action; read its header switch data-testid action-ledger-switch (aria-checked = the ledger flag, absence of a sys_metadata_activation row reads on). Flip it OFF (POST /api/v1/actions/_activation/OBJECT/ACTION), reload fully, re-open the action and record the switch, the list row's action-ledger-off-mark and the ledger row (metadata_type 'action', active false); flip it back ON. Then open a platform object in Studio by URL (e.g. /_console/studio/PLATFORM_PKG/data on sys_user, PLATFORM_PKG read off GET /api/v1/packages) and record that no action-ledger-switch renders on its actions", "refusal rendering (admin): open showcase_notify_owner in Studio and flip its auto-ledger-switch OFF — screenshot the studio-refusal strip after the 409 lands and read the role of studio-refusal-message", "refusal rendering + posture (plain member): sign in as the member IN A FRESH BROWSER CONTEXT (own session — both localStorage token and cookie, or the cell is still the admin's); open Setup and Studio and record what renders BEFORE any click; then flip a switch where a door is reachable, or else POST /api/v1/automation/showcase_urgent_task_alert/toggle {\"enabled\": false} as the member and capture the 403 body", - "lineage sweep: with the copy from step 6 present, search the Studio flow page, the rail and the Packaged actions page for any diff/'customized'/clonedFrom/lineage affordance" + "lineage sweep: with the copy from step 6 present, search the Studio flow page, the rail and the Data pillar's Actions view for any diff/'customized'/clonedFrom/lineage affordance" ], "acceptance": [ { - "clause": "the Setup navigation serves the Packaged actions entry and no longer the retired flows page: the served setup app carries the type:'component' item componentRef 'automation:packaged-actions' and none naming 'automation:packaged', clicking the sidebar entry lands on Setup › Packaged actions, and the retired page's bookmark lands in Studio (the cross-package flow list, or the named package's Automations pillar), never on a dead Setup page", + "clause": "the Setup navigation serves neither retired page: the served setup app carries no item naming 'automation:packaged-actions' or 'automation:packaged', the rendered sidebar has no Packaged actions entry, and each retired bookmark lands in Studio (the flows page: the cross-package flow list, or the named package's Automations pillar; the actions page: the Studio landing, or the named package's Data pillar), never on a dead Setup page", "oracle": "network", - "verify": "the GET /api/v1/meta/app?id=setup body carries id 'nav_packaged_actions', type 'component', componentRef 'automation:packaged-actions', label 'Packaged Actions' (setup-nav.contributions.ts), and nav_packaged_automation occurs 0 times (tombstoned in setup-nav-dead-key-tombstone.test.ts) — AND the sidebar click navigates to the page. The entry carries no requiresService and no requiredPermissions, as its predecessor did (the write doors gate server-side) — do not 'fix' either; it does carry visible: \"current_user.can('sys_metadata_activation', 'read')\" (#33224), the audience of its page's own ledger read, so a member who cannot read sys_metadata_activation is neither shown the entry nor landed on it. The bookmark legs are the navigation trace of steps[1]: /component/automation/packaged → /studio/~all/metadata/flow with no ?package=, → /studio/com.example.showcase/automations with one (packagedAutomationStudioPath; pinned by AppContent.setupMetadataStudio-28578.test.tsx). ⛔ A typed-URL landing does not tick the sidebar half: each repo half pins only itself (setup-packaged-actions-nav.test.ts; PackagedActionsPage.navContribution.test.tsx), and the live served body + real sidebar click is the only observation that crosses the seam", - "evidence": "the meta/app body + sidebar screenshot + the two bookmark navigation traces" + "verify": "the GET /api/v1/meta/app?id=setup body names neither nav_packaged_actions nor nav_packaged_automation, and neither ref (setup-nav.contributions.ts ships no group_apps entry; both ids are tombstoned in setup-nav-dead-key-tombstone.test.ts). The bookmark legs are the navigation traces of steps[1]: /component/automation/packaged → /studio/~all/metadata/flow with no ?package=, → /studio/com.example.showcase/automations with one (packagedAutomationStudioPath); /component/automation/packaged-actions → /studio with no ?package=, → /studio/com.example.showcase/data with one (packagedActionsStudioPath); both pinned by AppContent.setupMetadataStudio-28578.test.tsx. ⛔ A unit pin alone does not tick this clause: the live served body + the rendered sidebar are the only observation that crosses the repo seam", + "evidence": "the meta/app body + sidebar screenshot + the four bookmark navigation traces" }, { "clause": "inventory: Studio's Automations rail on the read-only showcase package lists exactly that package's packaged flows, each with a row in GET /api/v1/automation/_status, and an open flow's ledger switch is checked by default (an obsolete-status flow excepted: the engine holds it disabled). A flow the customization pair adds appears only with the rail row mark 'Added' (engine.customizationMark.added), never as one of the base's flows; 'In com.example.showcase.custom' (engine.studio.customize.addedIn) is the opened copy's header chip (StudioPairItemChip), not the rail row. This clause judges the flag, not the reading: on a default boot the two policy-unbound schedule flows keep a checked switch whose data-reading is 'not-running' (steps[3]), and that does not fail this clause", @@ -2420,15 +2420,15 @@ "evidence": "post-reload screenshot + the row read" }, { - "clause": "copying is offered on FLOWS only: an open packaged flow's ⋯ menu offers New similar, and Setup › Packaged actions offers no clone or copy affordance anywhere", + "clause": "copying is offered on FLOWS only: an open packaged flow's ⋯ menu offers New similar, and a vendor action's Actions view offers no clone or copy affordance anywhere", "oracle": "dom", - "verify": "auto-item-new-similar is present in the flow's menu; packaged-actions-section carries no clone/copy control (PackagedActionsSection.tsx header ⛔ 'No clone' — ADR-0126 §8 item 2 keeps the action clone pre-chartered). A clone control appearing on actions is a FAIL against the charter, not a bonus", - "evidence": "screenshots of the flow menu and the actions section" + "verify": "auto-item-new-similar is present in the flow's menu; the vendor action's header (action-ledger-bar) carries the switch and no clone/copy control (packagedActions.ts header ⛔ 'No clone target' — ADR-0126 §8 item 2 keeps the action clone pre-chartered). A clone control appearing on actions is a FAIL against the charter, not a bonus", + "evidence": "screenshots of the flow menu and the vendor action's header" }, { - "clause": "NO lineage surface: no diff-vs-base, no clonedFrom link, no drift indicator on the Studio flow page, its rail or the Packaged actions page — including after a copy exists. The pair's 'In com.example.showcase.custom' mark and a customization's own controls (ADR-0146 D2) say where an item is saved, not what it was copied from, and do not fail this clause", + "clause": "NO lineage surface: no diff-vs-base, no clonedFrom link, no drift indicator on the Studio flow page, its rail or the Data pillar's Actions view — including after a copy exists. The pair's 'In com.example.showcase.custom' mark and a customization's own controls (ADR-0146 D2) say where an item is saved, not what it was copied from, and do not fail this clause", "oracle": "dom", - "verify": "the step-10 sweep finds nothing that names the copy's source (ADR-0126 §9; FlowItemMoreMenu.tsx: 'No lineage is drawn … nothing here says what the copy was made from'; PackagedActionsSection.tsx ⛔ 'No drift or ancestry surface'). Displayed ancestry would mean a data source the platform ruled it does not track — its appearance is a FAIL even if it looks helpful", + "verify": "the step-10 sweep finds nothing that names the copy's source (ADR-0126 §9; FlowItemMoreMenu.tsx: 'No lineage is drawn … nothing here says what the copy was made from'; packagedActions.ts ⛔ 'No drift, ancestry or base-version fact'). Displayed ancestry would mean a data source the platform ruled it does not track — its appearance is a FAIL even if it looks helpful", "evidence": "full-page screenshots with the copy present" }, { @@ -2444,17 +2444,18 @@ "evidence": "dialog screenshots: disabled submit, the 400 alert text, the landing strip with its notice" }, { - "clause": "posture record (not a pass/fail gate): record whether a plain member REACHES Setup › Packaged actions or Studio's Automations pillar, which lists load, what the activation read answers, and where the first refusal arrives. Authored (#12438) against a posture where the member reached the page with open reads and met the refusal only after a click; QA run #29124 met a member refused at both Setup and Studio, with the activation read 403 and _status and /meta/action open (knownGaps[2]). Record the posture as observed", + "clause": "posture record (not a pass/fail gate): record whether a plain member REACHES Studio's Automations pillar or Data pillar, which lists load, what the activation read answers, and where the first refusal arrives. Authored (#12438) against a posture where the member reached the page with open reads and met the refusal only after a click; QA run #29124 met a member refused at both Setup and Studio, with the activation read 403 and _status and /meta/action open (knownGaps[2]). Record the posture as observed", "oracle": "dom", "verify": "sys_metadata_activation declares its reads open (apiMethods ['get', 'list'], 'Reads stay open so operability surfaces can answer \"what is disabled here?\"', sys-metadata-activation.object.ts) — but a member's read of it answered 403 in QA runs #23163, #26468 and #29124, so the declaration opens the verbs and the member's permission set grants no read. Record which the run meets. Whether that read-exposure is intended is a maintainer question tracked in the #12438 sweep's follow-ups — this clause RECORDS what a member sees; it does not adjudicate", "evidence": "the member's pre-click screenshots of both doors + the list of requests and their statuses" } ], "negative": [ - "ticking the nav clause off a typed-URL landing (or off either repo's unit pin alone) is the exact false positive this item exists to block — the page working and the page being findable are different facts", + "ticking the nav clause off a unit pin alone (either repo's) is the exact false positive this item exists to block — the served body and the rendered sidebar are different facts from the source", "scoring the member's refusal cell while the admin's token is still live in the browser context is an auth-state-leak — the strip would show a 409 (subflow) instead of the 403 (capability), silently proving the wrong clause", "a toggle whose switch flips back On after reload while the API row says active=false (or vice versa) is a FAIL wherever the mismatch lies — the switch must derive from the server, and the server must have written the row", - "a Setup page still listing packaged FLOWS, or a sidebar item naming 'automation:packaged', is a FAIL: two switches for one ledger row is the split ADR-0146 D11 retired" + "a Setup page still listing packaged FLOWS, or a sidebar item naming 'automation:packaged', is a FAIL: two switches for one ledger row is the split ADR-0146 D11 retired", + "an action-ledger-switch on a platform (kernel-package) action, or a Setup sidebar item naming 'automation:packaged-actions', is a FAIL: the maintainer ruled platform actions carry no switch anywhere (objectstack#34724)" ], "traps": [ "wrong-persona", @@ -2464,14 +2465,14 @@ ], "automated": { "kind": "test", - "ref": "ui/packages/app-shell/src/views/studio-design/AutomationsPillar.ledgerSwitch-28148.test.tsx (the ledger switch on a read-only package: binds the ledger flag, the off and not-running readings, the walled switch, the refusal verbatim, and 'announces the subflow guard's 409: one alert, the sentence verbatim, and again on a second refusal') + AutomationsPillar.newSimilar-28567.test.tsx (New similar: no target on a read-only base, the copy opened where the answer named, a 409 verbatim with the dialog kept open, no menu in the package-less scope) + StudioDesignSurface.refusalAnnounced-29139.test.tsx (the strip's sentence is the role=alert, 'Show me' and Details outside it) + ui/packages/app-shell/src/views/setup/PackagedActionsSection.test.tsx + PackagedActionsPage.navContribution.test.tsx + ui/packages/app-shell/src/console/__tests__/AppContent.setupMetadataStudio-28578.test.tsx (the retired page's bookmark → Studio) — all the MOCKED component half (stubbed fetch): they cannot evidence live refusal bodies or persistence, and score no clause on their own. The nav clause's framework half is pinned by packages/platform-objects/src/apps/setup-packaged-actions-nav.test.ts (entry present, ref/label/group, the deliberate absences); the served body + sidebar click still need the live run" + "ref": "ui/packages/app-shell/src/views/studio-design/AutomationsPillar.ledgerSwitch-28148.test.tsx (the ledger switch on a read-only package: binds the ledger flag, the off and not-running readings, the walled switch, the refusal verbatim, and 'announces the subflow guard's 409: one alert, the sentence verbatim, and again on a second refusal') + AutomationsPillar.newSimilar-28567.test.tsx (New similar: no target on a read-only base, the copy opened where the answer named, a 409 verbatim with the dialog kept open, no menu in the package-less scope) + StudioDesignSurface.refusalAnnounced-29139.test.tsx (the strip's sentence is the role=alert, 'Show me' and Details outside it) + ObjectActionsPanel.ledgerSwitch-34724.test.tsx (a read-only app's vendor action: the switch, the walled state, the refusal verbatim; none on a platform package or a writable one) + ui/packages/app-shell/src/console/__tests__/AppContent.setupMetadataStudio-28578.test.tsx (both retired pages' bookmarks → Studio) — all the MOCKED component half (stubbed fetch): they cannot evidence live refusal bodies or persistence, and score no clause on their own. The nav clause's framework half is pinned by packages/platform-objects/src/apps/setup-packaged-actions-nav.test.ts (neither retired entry or ref is contributed); the served body + sidebar click still need the live run" }, "source": [ - "docs/adr/0126-packaged-metadata-customization-model.md §7.4 (on/off + clone; ⛔ no drift/ancestry surface) as amended by docs/adr/0146-studio-designs-setup-administers-one-editor-per-item-paired-customize-package.md D4 (the packaged flow's switch and New similar move to the item in Studio; Setup › Packaged automation retires) and D11 (the retire list, N-28)", + "docs/adr/0126-packaged-metadata-customization-model.md §7.4 (on/off + clone; ⛔ no drift/ancestry surface) as amended by docs/adr/0146-studio-designs-setup-administers-one-editor-per-item-paired-customize-package.md D4 (the packaged flow's switch and New similar move to the item in Studio; Setup › Packaged automation retires) and D11 (the retire list, N-28); D4's amendment of 2026-11-17 (objectstack#34724) moves the packaged action's switch onto the action in Studio and retires Setup › Packaged actions", "ui/packages/app-shell/src/views/studio-design/FlowLedgerSwitch.tsx (auto-ledger-switch: aria-checked = the ledger flag, data-reading = activationReading) + FlowItemMoreMenu.tsx (New similar: copyValid disables submit; auto-new-similar-refusal role=alert) + StudioDesignSurface.tsx (toggleLedger, auto-new-similar-strip) + StudioRefusalStrip.tsx (studio-refusal-message role=alert, the one strip every pillar draws) + ui/packages/app-shell/src/views/setup/packagedFlows.ts (activationReading) + packagedFlowLedger.ts (requestFlowToggle)", - "ui/packages/app-shell/src/views/setup/PackagedActionsPage.tsx + PackagedActionsSection.tsx (header: ⛔ no clone, ⛔ no drift surface) + ui/packages/app-shell/src/services/builtinComponents.tsx (registerAppComponent ref 'automation:packaged-actions') + ui/packages/app-shell/src/views/studio-design/setupMetadataRedirect.ts#packagedAutomationStudioPath (the retired page's bookmark)", + "ui/packages/app-shell/src/views/studio-design/ObjectActionsPanel.tsx + metadata-admin/ResourceEditPage.tsx (action-ledger-switch, the vendor action's switch) + ui/packages/app-shell/src/views/setup/packagedActionLedger.ts (fetchActionLedger, requestActionToggle, useActionLedger: no switch for a package not served as an app package) + packagedActions.ts (header: ⛔ no clone target, ⛔ no drift) + ui/packages/app-shell/src/views/studio-design/setupMetadataRedirect.ts#packagedAutomationStudioPath and #packagedActionsStudioPath (the retired pages' bookmarks)", "objectui packages/core/src/actions/actionErrorDetail.ts (error → error.message → message; details[] dropped)", - "packages/platform-objects/src/apps/setup-nav.contributions.ts#nav_packaged_actions (nav_packaged_actions → componentRef 'automation:packaged-actions', pinned by setup-packaged-actions-nav.test.ts). It replaced nav_packaged_automation → 'automation:packaged' (#12457): the page's flows half retired into Studio's Automations pillar (ADR-0146 D11, #28578), and its actions half is this entry; nav_packaged_automation is tombstoned in setup-nav-dead-key-tombstone.test.ts", + "packages/platform-objects/src/apps/setup-nav.contributions.ts (no group_apps entry: nav_packaged_automation → 'automation:packaged' retired under ADR-0146 D11, #28578, and nav_packaged_actions → 'automation:packaged-actions' under the D4 amendment, objectstack#34724; both pinned absent by setup-packaged-actions-nav.test.ts and tombstoned in setup-nav-dead-key-tombstone.test.ts)", "packages/runtime/src/domains/automation.ts (the exact enablement 403 sentence)", "packages/platform-objects/src/system/sys-metadata-activation.object.ts (reads open)", "docs/adr/0054 (locator stability / UI-testability contract — the repo-ownership split recorded in fixtures)", @@ -2556,6 +2557,12 @@ "date": "2026-11-15", "change": "clause wording corrected, not narrowed, and verify-text correction. acceptance[1] (clause and verify): a pair-added flow carries the rail row mark 'Added' (engine.customizationMark.added); 'In com.example.showcase.custom' is the opened copy's header chip. acceptance[0].verify names the entry's visible gate, current_user.can('sys_metadata_activation', 'read') (setup-nav.contributions.ts). Read from source at base 895783a1. Source records: QA record #33853 (comment 6894307378) on #33761. Batch D of the #33761 close-out, card #33966", "ref": "#33984" + }, + { + "revision": 14, + "date": "2026-11-17", + "change": "Setup › Packaged actions retired (objectstack#34724, the ADR-0146 D4 amendment of 2026-11-17): a read-only app's vendor action carries the ledger switch on its Actions view in Studio, a platform action none, and the page's bookmark lands in Studio. title, fixtures (requires[1], knownGaps[0..1]), steps[1], steps[6], steps[9], acceptance[0], [3], [4], [7], negative[0] (and one new negative), automated and source re-pointed. Read from source; no QA run has driven the Studio action switch yet.", + "ref": "#34724" } ] }, diff --git a/docs/qa/platform-checklist/areas/platform-core.json b/docs/qa/platform-checklist/areas/platform-core.json index 6e6231ad205..1251cd4d479 100644 --- a/docs/qa/platform-checklist/areas/platform-core.json +++ b/docs/qa/platform-checklist/areas/platform-core.json @@ -640,7 +640,7 @@ "title": "The built-in apps a stock boot REGISTERS (Setup / Account) render every merged-nav destination; app-level and entry-level gates are enforced, not errored — and Studio's deliberate absence is asserted, never hunted", "since": "v15", "status": "active", - "revision": 15, + "revision": 16, "priority": "P0", "surface": "browser", "personas": [ @@ -665,7 +665,7 @@ "as admin, hand-walk each destination in each app. At a window narrower than 1416 px (1280 px included) the console folds the sidebar to its icon rail, and Setup and Account open that way (ui/packages/app-shell/src/layout/consoleSidebarRail.ts CONSOLE_SIDEBAR_RAIL_BELOW_WIDTH, objectstack#27593; QA run #29877 met it at 1280 px): press the sidebar toggle at the app bar's left edge (Ctrl/⌘+B) to unfold it before expanding any group. EXPAND every nav group first: some render collapsed by default — Setup's Advanced group and Account's Developer group declare `expanded: false` (packages/platform-objects/src/apps/setup.app.ts, account.app.ts), and QA run #24557 found Setup's Configuration group collapsed as well — so a walk that never expands them never reaches their entries. Then navigate, wait for render, SCREENSHOT FIRST, then read the DOM — assert no pageerror, no 'failed to load', no blank
, no 'no actions configured' placeholder", "Setup detail: confirm each settings URL entry (nav_settings_* → /apps/setup/system/settings/) opens the settings namespace form — the 11 namespaces of a stock single-posture boot, localization/company/branding/auth/access_policy/mail/sms/storage/ai/knowledge/lifecycle: the nav_settings_* entries of packages/platform-objects/src/apps/setup-nav.contributions.ts, plus nav_settings_branding, which packages/services/service-settings/src/settings-service-plugin.ts contributes only where no organization wall stands, and Users / Organization / Business Units / Teams / Sessions / OAuth Applications render. User preferences and identity links are not Setup destinations: open a user's record page, /_console/apps/setup/sys_user/record/ID (a row click on the Users list opens a side panel at ?recordId=, which is not that page: take the id from the row or the panel), and confirm the user page's Preferences and Linked Accounts tabs (packages/platform-objects/src/pages/sys-user.page.ts#SysUserDetailPage) render that user's rows", "Studio detail is NOT walked from here — the app is not registered on a stock boot (knownGap), so there is no merged nav to render. Its metadata:resource lists and component surfaces (App Builder, All Metadata Types, Packages, API Console, Flow Runs, Public Forms) are reached through the console surface at /_console/studio// and are covered by area studio-authoring. What THIS item asserts about Studio is the absence itself, per clause 6", - "Account detail: confirm Profile (account:profile_card), Notifications (sys_inbox_message/mine), Approvals (nav_account_approvals, the approvals:inbox component, served as …/component/approvals/inbox — the Approvals Inbox, not the sys_approval_request grid; account.app.ts), Linked Accounts (sys_account), Active Sessions (sys_session/mine), API Keys (sys_api_key/mine), OAuth Applications (sys_oauth_application/mine) and Connect an Agent (nav_connect_agent) each render — 8 Account destinations and 48 Setup destinations for the admin on a stock single-org showcase boot, as QA runs #32953 (at 5fb79bc0) and #33087 (at 8e3d4a54) read them (GET /api/v1/meta/app leaves, which match the nav source minus its gates). QA run #29877 read 46 at 589049b0, before Access policy (nav_settings_access_policy, the access_policy namespace) joined the Configuration group. Since QA run #28545's reading Setup's Packaged automation page retired under ADR-0146 D11, leaving Packaged Actions (nav_packaged_actions, automation:packaged-actions; #28785), and its unfiltered Packages entry moved to Studio (#29547) (47 for #28927, 50 at eeec88d1 for QA run #28545, 48 re-measured at 3fd80337 for #28338, QA run #27481 read 44 and 8, QA run #24557 read 42 at 5b14b7f3, 45 on 2026-10-01, and #9453 recorded 43 and 7). Recount from the payload each run", + "Account detail: confirm Profile (account:profile_card), Notifications (sys_inbox_message/mine), Approvals (nav_account_approvals, the approvals:inbox component, served as …/component/approvals/inbox — the Approvals Inbox, not the sys_approval_request grid; account.app.ts), Linked Accounts (sys_account), Active Sessions (sys_session/mine), API Keys (sys_api_key/mine), OAuth Applications (sys_oauth_application/mine) and Connect an Agent (nav_connect_agent) each render — 8 Account destinations and 47 Setup destinations for the admin on a stock single-org showcase boot, read from source after objectstack#34724 retired Setup › Packaged Actions (nav_packaged_actions; its switch moved onto the action in Studio); QA runs #32953 (at 5fb79bc0) and #33087 (at 8e3d4a54) read 48 before it (GET /api/v1/meta/app leaves, which match the nav source minus its gates). QA run #29877 read 46 at 589049b0, before Access policy (nav_settings_access_policy, the access_policy namespace) joined the Configuration group. Since QA run #28545's reading Setup's Packaged automation page retired under ADR-0146 D11, leaving Packaged Actions (nav_packaged_actions, automation:packaged-actions; #28785, itself retired by objectstack#34724), and its unfiltered Packages entry moved to Studio (#29547) (47 for #28927, 50 at eeec88d1 for QA run #28545, 48 re-measured at 3fd80337 for #28338, QA run #27481 read 44 and 8, QA run #24557 read 42 at 5b14b7f3, 45 on 2026-10-01, and #9453 recorded 43 and 7). Recount from the payload each run", "confirm the gated entries resolve to ABSENT-not-erroring for the admin: nav_organizations (requiresService org-scoping) is absent in single-org mode; nav_jwks Signing Keys is ABSENT for EVERY persona, admin included — the entry was removed in #7544 because sys_jwks declares apiEnabled:false, so its list answers OBJECT_API_DISABLED (404) for all callers and no permission gate could prune it; SSO Providers is absent unless OS_SSO_ENABLED (knownGap)", "sign in as the plain member: attempt to open Setup (app name setup) — capture the app-level refusal (App.requiredPermissions setup.access); open Account (declares no requiredPermissions) — capture it opening. Studio is not part of this comparison: it is absent for EVERY persona including the admin, so a member failing to reach it proves nothing about the gate (the same reasoning #7544 applied to nav_jwks)", "as the member, GET /api/v1/meta/app for a reachable app and confirm every manage_platform_settings-gated entry (API Keys, the manage_platform_settings settings URLs) is ABSENT from the member's payload — the server prunes, the client does not merely hide. JWKS is deliberately NOT in this list any more: it is absent for admins too, so finding it absent for a member proves nothing about the gate (#7544)", @@ -810,6 +810,12 @@ "date": "2026-11-15", "change": "steps[3] names the user record URL (row 8 of ledger 6896511848 on #33761; QA run #33784 at a557fa38): a row click on the Setup Users list opens a side panel (?recordId=), and the Preferences and Linked Accounts tabs live on the record page (/apps/setup/sys_user/record/ID, the sys_user_detail page). No clause changed. Read from source at base 0ac112fc", "ref": "#34004" + }, + { + "revision": 16, + "date": "2026-11-17", + "change": "steps[5]: the admin's Setup destinations are 47, not 48: Setup › Packaged Actions (nav_packaged_actions) retired, its switch moved onto the action in Studio (the ADR-0146 D4 amendment of 2026-11-17). Read from source; not yet re-measured by a QA run.", + "ref": "#34724" } ] }, diff --git a/packages/cli/test/setup-landing-audience.pin.test.ts b/packages/cli/test/setup-landing-audience.pin.test.ts index 70350f5b246..d51c3e5a1bb 100644 --- a/packages/cli/test/setup-landing-audience.pin.test.ts +++ b/packages/cli/test/setup-landing-audience.pin.test.ts @@ -13,18 +13,20 @@ // entry wins; an entry whose `visible` is false is not shown, and an `object` // entry is pruned when the member may not read its object (objectui#12109). // -// Setup's first served entry is Packaged Actions (`nav_packaged_actions`, a -// `component`). Its page reads `/data/sys_metadata_activation`, and the -// object-read prune does not judge a `component` entry, so before #33224 every -// member landed there: a separation-of-duties officer whose ledger read -// answers 403 opened Setup on `activation ledger HTTP 403`. The entry now -// carries `visible: current_user.can('sys_metadata_activation', 'read')`, and: +// Setup's first served entry used to be Packaged Actions +// (`nav_packaged_actions`, a `component`). Its page read +// `/data/sys_metadata_activation`, and the object-read prune does not judge a +// `component` entry, so before #33224 every member landed there: a +// separation-of-duties officer whose ledger read answers 403 opened Setup on +// `activation ledger HTTP 403`. #33224 gave the entry the ledger-read audience. +// objectstack#34724 (the ADR-0146 D4 amendment of 2026-11-17) then retired the +// entry and its page: a packaged action's switch is on the action, in Studio. +// So now: // -// - an officer who may not read the ledger, and may read users, lands on -// People & Org › Users (`nav_users`); -// - a member who may read the ledger lands on Packaged Actions, as before; -// - the platform administrator still lands on System Overview, which is -// served to them ahead of Packaged Actions, and is still shown the entry. +// - no Packaged Actions entry is served, to anyone; +// - an officer who may read users lands on People & Org › Users +// (`nav_users`), whatever their ledger read; +// - the platform administrator still lands on System Overview. // // The served `/meta/app/setup` tree is real (shell, contributions, registry // fold, per-request filter); the landing walk below restates the console's two @@ -191,18 +193,15 @@ function entries(items: AnyRec[] | undefined): AnyRec[] { const OFFICER = ['setup.access', 'view_all_audit_log']; describe('Setup lands each member on an entry whose page they can read (#33224)', () => { - it('Packaged Actions is served with the ledger-read audience its page needs', async () => { - const setup = await servedSetup(OFFICER); - const packaged = entries(setup.navigation).find((i) => i.id === 'nav_packaged_actions'); - expect(packaged).toMatchObject({ - type: 'component', - componentRef: 'automation:packaged-actions', - visible: "current_user.can('sys_metadata_activation', 'read')", - }); - // Control: it is still the FIRST landing-type entry served, so the - // predicate is what moves the officer's landing, not the order. - const firstLanding = entries(setup.navigation).find((i) => LANDING_TYPES.has(i.type)); - expect(firstLanding?.id).toBe('nav_packaged_actions'); + it('no Packaged Actions entry is served: the page retired (objectstack#34724)', async () => { + for (const permissions of [OFFICER, ADMIN_FULL_ACCESS_CAPABILITIES.systemPermissions ?? []]) { + const setup = await servedSetup(permissions); + const served = entries(setup.navigation); + // Control: the walk reads the served tree. + expect(served.some((i) => i.id === 'nav_users')).toBe(true); + expect(served.filter((i) => i.id === 'nav_packaged_actions')).toEqual([]); + expect(served.filter((i) => i.componentRef === 'automation:packaged-actions')).toEqual([]); + } }); it('an officer who may not read the activation ledger lands on Users, not on a 403 page', async () => { @@ -211,7 +210,7 @@ describe('Setup lands each member on an entry whose page they can read (#33224)' expect(landingFor(setup, officer)).toBe('nav_users'); }); - it('a member who may read the activation ledger still lands on Packaged Actions', async () => { + it('a member who may read the activation ledger lands on Users too: no ledger page is ahead of it', async () => { // Same served tree as the officer's; only the ledger read differs. const setup = await servedSetup(OFFICER); const reader = { @@ -219,20 +218,15 @@ describe('Setup lands each member on an entry whose page they can read (#33224)' sys_audit_log: { allowRead: true }, sys_user: { allowRead: true }, }; - expect(landingFor(setup, reader)).toBe('nav_packaged_actions'); + expect(landingFor(setup, reader)).toBe('nav_users'); }); - it('the platform administrator lands where they did before, and is still shown Packaged Actions', async () => { + it('the platform administrator lands where they did before', async () => { const setup = await servedSetup(ADMIN_FULL_ACCESS_CAPABILITIES.systemPermissions ?? []); const admin = { sys_metadata_activation: { allowRead: true, viewAllRecords: true }, sys_user: { allowRead: true, viewAllRecords: true }, }; - // The administrator's first served entry is the System Overview, ahead - // of Packaged Actions; the predicate does not move it. expect(landingFor(setup, admin)).toBe('nav_system_overview'); - const packaged = entries(setup.navigation).find((i) => i.id === 'nav_packaged_actions'); - expect(packaged).toBeDefined(); - expect(landingFor({ navigation: [packaged] }, admin)).toBe('nav_packaged_actions'); }); }); diff --git a/packages/objectql/src/action-activation.test.ts b/packages/objectql/src/action-activation.test.ts index 0ed4b87a974..5da7988710b 100644 --- a/packages/objectql/src/action-activation.test.ts +++ b/packages/objectql/src/action-activation.test.ts @@ -317,8 +317,8 @@ describe('ActionActivationProjection — absence means ACTIVE', () => { // What happened, who can undo it and where, and what to do meanwhile. expect(message).toBe( - 'This action is turned off for this deployment. An administrator can turn it on again under ' - + 'Setup › Packaged Actions, or you can use another action.', + 'This action is turned off for this deployment. An administrator can turn it on again ' + + 'on the action in its package in Studio, or you can use another action.', ); // The machine half (the ledger table, the ADR) belongs to the log line // and the envelope's code, never to what an end user reads. @@ -406,6 +406,35 @@ describe('ObjectQL engine — the projection the dispatch doors consult', () => expect(meta).toEqual({ action: 'convert_lead', refusal: 'ACTION_DISABLED' }); }); + // [objectstack#34724, ruling 6944409840] Studio offers no switch for a + // platform (kernel-package) action, and a row written before Setup's page + // retired stays in force, so that action's sentence names the activation + // door. The package is the one the ledger row names, judged against the + // registry's installed manifest (`scope` `system` / `cloud`). + it('a switched-off platform action\'s sentence names the activation door; an app action\'s names Studio', async () => { + const engine = new ObjectQL(); + const manifest = (id: string, scope?: string) => + ({ id, name: id, version: '1.0.0', type: 'plugin', namespace: id.split('.').pop(), ...(scope ? { scope } : {}) }) as any; + engine.registry.installPackage(manifest('com.objectstack.plugin-auth', 'system'), 'code'); + engine.registry.installPackage(manifest('com.example.crm'), 'code'); + const store = new InMemoryActionActivationStore(); + await store.setActive({ name: 'ban_user', packageId: 'com.objectstack.plugin-auth', active: false }); + await store.setActive({ name: 'convert_lead', packageId: 'com.example.crm', active: false }); + engine.setActionActivationStore(store); + await engine.hydrateActionActivations(); + + expect(engine.describeDisabledAction('ban_user')).toBe(describeTurnedOffPackagedItem('action', { platform: true })); + expect(engine.describeDisabledAction('ban_user')).toContain('POST /api/v1/actions/_activation/'); + expect(engine.describeDisabledAction('convert_lead')).toBe(describeTurnedOffPackagedItem('action')); + + // A flip made after boot carries its package the same way. + await engine.setActionActive({ name: 'revoke_api_key', packageId: 'com.objectstack.plugin-auth', active: false }); + expect(engine.describeDisabledAction('revoke_api_key')).toBe(describeTurnedOffPackagedItem('action', { platform: true })); + // A row naming no package, or a package not installed, is not judged a platform one. + await engine.setActionActive({ name: 'env_action', active: false }); + expect(engine.describeDisabledAction('env_action')).toBe(describeTurnedOffPackagedItem('action')); + }); + it('setActionActive flips the row and the projection together, in that order', async () => { const engine = new ObjectQL(); const store = new InMemoryActionActivationStore(); diff --git a/packages/objectql/src/action-activation.ts b/packages/objectql/src/action-activation.ts index 909aa1ef22d..d596dfd0517 100644 --- a/packages/objectql/src/action-activation.ts +++ b/packages/objectql/src/action-activation.ts @@ -199,8 +199,13 @@ export class ObjectStoreActionActivationStore extends ObjectStoreMetadataActivat * re-register" pin asserts. */ export class ActionActivationProjection { - /** Actions the ledger marks inactive, keyed by declarative name. */ - private readonly disabled = new Set(); + /** + * Actions the ledger marks inactive, keyed by declarative name, each with + * the package its row names (absent for an environment-authored action): + * the refusal sentence reads it to tell a platform action, which Studio + * offers no switch for, from an app's (objectstack#34724). + */ + private readonly disabled = new Map(); private store: ActionActivationStore | null = null; /** Attach the durable ledger. Hosts call this at start(), after ObjectQL is up. */ @@ -229,7 +234,7 @@ export class ActionActivationProjection { this.disabled.delete(row.name); continue; } - this.disabled.add(row.name); + this.disabled.set(row.name, row.packageId); off.push(row.name); } return off; @@ -245,7 +250,15 @@ export class ActionActivationProjection { /** Every action name the ledger currently switches off (operability reads). */ disabledNames(): string[] { - return [...this.disabled]; + return [...this.disabled.keys()]; + } + + /** + * The package the ledger row of a switched-off action names, or + * `undefined` when the action is not switched off or its row names none. + */ + disabledPackageOf(name: string): string | undefined { + return this.disabled.get(name); } /** @@ -283,7 +296,7 @@ export class ActionActivationProjection { } await this.store.setActive(row, options); if (row.active) this.disabled.delete(row.name); - else this.disabled.add(row.name); + else this.disabled.set(row.name, row.packageId); } /** @@ -313,8 +326,14 @@ export class ActionActivationProjection { * (`@objectstack/types`), the one the flow refusal reads as too, so the * two switched-off packaged items are stated in one shape, not two that * agree today. + * + * `platform` is the caller's verdict that the row's package is a kernel + * package (`ObjectQL.describeDisabledAction` judges it against the + * registry): Studio offers no switch for a platform action (ADR-0146 D4 + * as amended 2026-11-17), so that sentence names the activation door + * instead (maintainer ruling 6944409840). */ - describeDisabled(_name: string): string { - return describeTurnedOffPackagedItem('action'); + describeDisabled(_name: string, platform = false): string { + return describeTurnedOffPackagedItem('action', { platform }); } } diff --git a/packages/objectql/src/engine-actions.ts b/packages/objectql/src/engine-actions.ts index faff736d12b..4efb9d8433c 100644 --- a/packages/objectql/src/engine-actions.ts +++ b/packages/objectql/src/engine-actions.ts @@ -140,6 +140,22 @@ export interface ActionsHost { readonly registry: ObjectQL['registry']; } +/** + * The manifest scopes of a kernel package: the platform's own (`system`) and + * the control plane's (`cloud`). The same list as `@objectstack/metadata-protocol`'s + * `READ_ONLY_PACKAGE_SCOPES` and `@objectstack/metadata-core`'s + * `KERNEL_PACKAGE_SCOPES`; spelled here because this module is inside the + * `./core` closure, which must not import metadata-protocol (ADR-0076 D2, + * `core-boundary.ratchet.test.ts`), and metadata-core does not export it. + */ +const KERNEL_PACKAGE_SCOPES: readonly string[] = ['system', 'cloud']; + +/** Is `manifest` a kernel package's — scope `system` or `cloud`? */ +function isKernelPackageScope(manifest: unknown): boolean { + const scope = (manifest as { scope?: unknown } | null | undefined)?.scope; + return typeof scope === 'string' && KERNEL_PACKAGE_SCOPES.includes(scope); +} + /** The bodies of the "Action system and packaged-action activation" section of `ObjectQL`: a stateless facet, called by the class's stubs. */ export class ActionsFacet { /** The body of `ObjectQL#registerAction`; the method's docblock there is its contract. */ @@ -510,13 +526,19 @@ export class ActionsFacet { } /** The body of `ObjectQL#describeDisabledAction`; the method's docblock there is its contract. */ - static describeDisabledAction(this: Pick, actionName: string): string { + static describeDisabledAction(this: Pick, actionName: string): string { this.logger.info( `ACTION_DISABLED: packaged action '${actionName}' refused — it is switched off in the activation ledger ` + '(sys_metadata_activation, ADR-0126 §8 item 2).', { action: actionName, refusal: 'ACTION_DISABLED' }, ); - return this.actionActivation.describeDisabled(actionName); + // [objectstack#34724, ruling 6944409840] A platform (kernel-package) + // action has no switch in Studio, so its sentence names the activation + // door; the package is the one the ledger row names, judged by the + // registry's installed manifest. + const packageId = this.actionActivation.disabledPackageOf(actionName); + const platform = packageId !== undefined && isKernelPackageScope(this.registry.getPackage(packageId)?.manifest); + return this.actionActivation.describeDisabled(actionName, platform); } /** The body of `ObjectQL#setActionActive`; the method's docblock there is its contract. */ diff --git a/packages/platform-objects/src/apps/setup-nav.contributions.ts b/packages/platform-objects/src/apps/setup-nav.contributions.ts index 54bf41c515f..28ba9e146ad 100644 --- a/packages/platform-objects/src/apps/setup-nav.contributions.ts +++ b/packages/platform-objects/src/apps/setup-nav.contributions.ts @@ -38,53 +38,26 @@ export const SETUP_NAV_CONTRIBUTIONS: NavigationContribution[] = [ { id: 'nav_system_overview', type: 'dashboard', label: 'System Overview', dashboardName: 'system_overview', icon: 'activity' }, ], }, - { - // No unfiltered Packages entry here (#25098, ruling 甲 amending #23892 B): - // the full `developer:packages` list is a development surface, so its one - // unfiltered door is Studio's Overview → Packages (`studio.app.ts`). Setup - // reaches installed packages through the marketplace-filtered "Installed - // Apps" door (`nav_marketplace_installed`, `developer:packages` with - // `params: { source: 'marketplace' }`), which - // `@objectstack/cloud-connection` contributes to this group wherever the - // marketplace capability is present. `setup-packages-door.test.ts` pins - // both halves. - app: 'setup', - group: 'group_apps', - priority: BASE_PRIORITY, - items: [ - // Packaged actions are OPERATIONAL state — on/off per packaged action - // (ADR-0126 §7.4: "Studio keeps the editing; Setup gets the operational - // state"). ADR-0146 D4 keeps the action switch here while the flow - // switch moved onto the flow's item in Studio, and its clone became - // Studio's New similar (D11 retired Setup's packaged FLOWS page). The - // console binds `automation:packaged-actions` to the packaged-actions - // page (objectui app-shell `builtinComponents`). The entry lives HERE, - // not in service-automation: the page's data source is the - // `sys_metadata_activation` ledger this package registers (#12419), and - // the action switches work on compositions with no automation service — - // a nav entry riding that service would hide a page that still works - // there. - // - // `visible` gives the entry the audience of its page's own data read - // (#33224). The page reads `/data/sys_metadata_activation`, and a member - // who may not read that ledger was shown an entry whose page renders only - // `activation ledger HTTP 403`. Being the first entry the Setup app - // serves, it was also their LANDING page: the console's object-read prune - // judges `type: 'object'` entries only, so nothing else hid this - // `component` one. The console's sidebar and its landing walk ask this - // predicate with the member's `/auth/me/permissions` map, so such a member - // now neither sees the entry nor lands on it. A member who reads the - // ledger is shown it as before. - { - id: 'nav_packaged_actions', - type: 'component', - label: 'Packaged Actions', - componentRef: 'automation:packaged-actions', - icon: 'zap', - visible: "current_user.can('sys_metadata_activation', 'read')", - }, - ], - }, + // No `group_apps` entry ships from this package. + // + // No unfiltered Packages entry (#25098, ruling 甲 amending #23892 B): the + // full `developer:packages` list is a development surface, so its one + // unfiltered door is Studio's Overview → Packages (`studio.app.ts`). Setup + // reaches installed packages through the marketplace-filtered "Installed + // Apps" door (`nav_marketplace_installed`, `developer:packages` with + // `params: { source: 'marketplace' }`), which + // `@objectstack/cloud-connection` contributes to this group wherever the + // marketplace capability is present. `setup-packages-door.test.ts` pins + // both halves. + // + // And no Packaged Actions entry (objectstack#34724, the ADR-0146 D4 + // amendment of 2026-11-17): a packaged action's on/off switch for this + // deployment is on the action, in its app in Studio (the object's Actions + // view, a standalone action's item page), the way D4 put the flow switch on + // the flow. The `nav_packaged_actions` entry and its + // `automation:packaged-actions` page retired, as `nav_packaged_automation` + // did under D11; the console sends the old URL to Studio. + // `setup-packaged-actions-nav.test.ts` pins both retirements. { app: 'setup', group: 'group_people_org', diff --git a/packages/platform-objects/src/apps/setup-packaged-actions-nav.test.ts b/packages/platform-objects/src/apps/setup-packaged-actions-nav.test.ts index 62b65d8009c..ffab569c822 100644 --- a/packages/platform-objects/src/apps/setup-packaged-actions-nav.test.ts +++ b/packages/platform-objects/src/apps/setup-packaged-actions-nav.test.ts @@ -1,120 +1,61 @@ // Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license. // -// The Setup app's Packaged Actions entry points at the -// `automation:packaged-actions` COMPONENT the console registers, and the -// retired Packaged Automation entry stays retired (ADR-0146 D4, D11). +// Setup ships no packaged-automation page any more: neither the retired +// Packaged Automation entry (ADR-0146 D11) nor the retired Packaged Actions +// entry (objectstack#34724, the ADR-0146 D4 amendment of 2026-11-17). // -// Why this needs a pin rather than a code comment: the page is objectui's (app- -// shell `PackagedActionsPage`, registered under `automation:packaged-actions` -// in `builtinComponents`, pinned there by `PackagedActionsPage.navContribution -// .test.tsx`), and nothing at runtime says when the framework entry naming the -// ref goes missing: the page is then reachable only by a hand-typed URL. This -// file is the framework half of that cross-repo contract; the REF LITERAL below -// and objectui's `REF` constant must agree, and each side pins its own. +// What retired, and where each switch went: +// - Setup › Packaged automation's FLOWS half moved into Studio (D4 put the +// flow switch on the flow's item, and its clone became Studio's New +// similar), so `nav_packaged_automation`, its `automation:packaged` ref and +// its page retired (D11). +// - Its ACTIONS half stayed in Setup as `nav_packaged_actions` +// (`automation:packaged-actions`) until the maintainer's 2026-11-17 call on +// objectstack#34724 (「打包动作不是应该在 studio 对应的软件包中自定义吗」): +// a packaged action's switch is now on the action, in its app in Studio, +// and the platform's own actions carry no switch. The entry and the page +// retired; the console sends a bookmark of the page to Studio. // -// What retired, and why the converse is pinned too: Setup › Packaged -// automation's FLOWS half moved into Studio (D4 put the flow switch on the -// flow's item, and its clone became Studio's New similar), so its entry, its -// `automation:packaged` ref and its page retired (D11). D4 keeps the ACTION -// switch where it was, so the actions half stays in Setup as its own entry. -// -// Its audience is its page's own data read, and nothing else (#33224): -// - `visible: current_user.can('sys_metadata_activation', 'read')` — the page -// reads the ledger, so a member who may not read it is not shown the entry -// and does not land on it. This entry used to carry no audience at all; that -// was a developer choice (#12491), not a ruling, and it made the entry the -// Setup landing page of every member, including a separation-of-duties -// officer whose ledger read answers 403, so the officer's Setup opened on -// `activation ledger HTTP 403` (#33224). The console's object-read prune -// judges `type: 'object'` entries only, so a `component` entry needs its own. -// - still no `requiresService: 'automation'` — the action switches ride the -// `sys_metadata_activation` ledger this package registers (#12419) and work -// on compositions with NO automation service; gating the entry on that -// service would hide a page that still works there. -// - still no `requiredPermissions` — like the rest of `group_apps`: the Setup -// app's own `setup.access` gates the app, and the activation WRITE doors -// enforce `manage_metadata` / the ADR-0126 §5 operator gate server-side. A -// capability gate here would hide the page from a member who may read the -// ledger, and the page reads, not writes, to render. +// Why a pin: a re-added entry would render with nothing behind it (the +// console registers no component under either ref, and its router redirects +// both URLs to Studio), so nothing at runtime says it came back. import { describe, it, expect } from 'vitest'; -import { NavigationContributionSchema } from '@objectstack/spec/ui'; import { SETUP_NAV_CONTRIBUTIONS } from './setup-nav.contributions.js'; type NavItem = { id?: string; - type?: string; - label?: string; componentRef?: string; - requiresService?: string; - requiredPermissions?: string[]; - visible?: string; children?: NavItem[]; }; -/** Every contributed Setup nav item, depth-first, with its owning group. */ -const allItems = (): Array<{ group?: string; item: NavItem }> => { - const out: Array<{ group?: string; item: NavItem }> = []; - for (const c of SETUP_NAV_CONTRIBUTIONS) { - const walk = (items: NavItem[] = []) => { - for (const item of items) { - if (!item) continue; - out.push({ group: c.group, item }); - if (Array.isArray(item.children)) walk(item.children); - } - }; - walk((c.items ?? []) as NavItem[]); - } +/** Every contributed Setup nav item, depth-first. */ +const allItems = (): NavItem[] => { + const out: NavItem[] = []; + const walk = (items: NavItem[] = []) => { + for (const item of items) { + if (!item) continue; + out.push(item); + if (Array.isArray(item.children)) walk(item.children); + } + }; + for (const c of SETUP_NAV_CONTRIBUTIONS) walk((c.items ?? []) as NavItem[]); return out; }; -const entry = (): { group?: string; item: NavItem } => { - const found = allItems().find(({ item }) => item.id === 'nav_packaged_actions'); - expect(found, 'Setup lost its nav_packaged_actions entry').toBeDefined(); - return found as { group?: string; item: NavItem }; -}; - -describe('the Setup Packaged Actions entry targets the console component (ADR-0146 D4)', () => { - it('routes to the `automation:packaged-actions` registry key', () => { - expect(entry().item).toMatchObject({ - type: 'component', - componentRef: 'automation:packaged-actions', - label: 'Packaged Actions', - }); - }); - - it('lives in group_apps — operational package state is Operate (ADR-0084)', () => { - expect(entry().group).toBe('group_apps'); - }); - - it('does not gate on the automation service (the action switches work without it, #12419)', () => { - expect(entry().item.requiresService).toBeUndefined(); - expect(entry().item.requiredPermissions).toBeUndefined(); - }); +describe('Setup ships no packaged-automation page (ADR-0146 D4 as amended, D11)', () => { + it('no entry names a retired id or a retired ref', () => { + const items = allItems(); + // Control: the walk reads the real array. + expect(items.some((i) => i.id === 'nav_users')).toBe(true); - it("is shown to the members who may read the ledger its page reads (#33224)", () => { - // The page's data source is `/data/sys_metadata_activation`; the - // predicate names that object and the `read` verb, nothing broader. - expect(entry().item.visible).toBe("current_user.can('sys_metadata_activation', 'read')"); - }); - - it('parses as a NavigationContribution the runtime merge accepts', () => { - const contribution = SETUP_NAV_CONTRIBUTIONS.find((c) => - (c.items ?? []).some((i) => (i as NavItem).id === 'nav_packaged_actions'), - ); - expect(contribution).toBeDefined(); - expect(() => NavigationContributionSchema.parse(contribution)).not.toThrow(); - }); -}); - -describe('Setup › Packaged automation stays retired (ADR-0146 D11)', () => { - it('no entry names the retired id or the retired `automation:packaged` ref', () => { - const items = allItems().map(({ item }) => item); - // Control: the walk reads the real array. (It used to name Setup's - // `nav_packages`, which moved to Studio in #25098; - // `setup-packages-door.test.ts` pins that move.) - expect(items.some((i) => i.id === 'nav_packaged_actions')).toBe(true); expect(items.filter((i) => i.id === 'nav_packaged_automation')).toEqual([]); expect(items.filter((i) => i.componentRef === 'automation:packaged')).toEqual([]); + expect(items.filter((i) => i.id === 'nav_packaged_actions')).toEqual([]); + expect(items.filter((i) => i.componentRef === 'automation:packaged-actions')).toEqual([]); + }); + + it('no contribution is an empty group_apps shell left behind', () => { + expect(SETUP_NAV_CONTRIBUTIONS.filter((c) => c.group === 'group_apps')).toEqual([]); }); }); diff --git a/packages/platform-objects/src/apps/setup-packages-door.test.ts b/packages/platform-objects/src/apps/setup-packages-door.test.ts index 03e76374b5e..39f31935de4 100644 --- a/packages/platform-objects/src/apps/setup-packages-door.test.ts +++ b/packages/platform-objects/src/apps/setup-packages-door.test.ts @@ -66,7 +66,7 @@ describe('the unfiltered package list is a Studio surface, not a Setup one (#250 const items = setupItems(); // Control: the walk reads the real Setup shell and its contributions. expect(items.some((i) => i.id === 'group_apps')).toBe(true); - expect(items.some((i) => i.id === 'nav_packaged_actions')).toBe(true); + expect(items.some((i) => i.id === 'nav_users')).toBe(true); expect(items.filter(isUnfilteredPackagesDoor)).toEqual([]); expect(items.filter((i) => i.id === 'nav_packages')).toEqual([]); diff --git a/packages/platform-objects/src/apps/translations/ar.source-hashes.ts b/packages/platform-objects/src/apps/translations/ar.source-hashes.ts index f73111efd90..01b4dbfe7bc 100644 --- a/packages/platform-objects/src/apps/translations/ar.source-hashes.ts +++ b/packages/platform-objects/src/apps/translations/ar.source-hashes.ts @@ -73,7 +73,6 @@ export const arSourceHashes: Readonly> = { 'apps.setup.description': 'deacdfc679232a4a', 'apps.setup.navigation.group_overview.label': 'eebdbe1cc7b59cdf', 'apps.setup.navigation.group_apps.label': '699b367291abcbe6', - 'apps.setup.navigation.nav_packaged_actions.label': '0d86b11df972dff3', 'apps.setup.navigation.nav_marketplace_browse.label': '2afbe021f5419fdd', 'apps.setup.navigation.nav_marketplace_installed.label': '93bd5d458e05db60', 'apps.setup.navigation.nav_cloud_connection.label': '3a7caad0cb98e71d', diff --git a/packages/platform-objects/src/apps/translations/ar.ts b/packages/platform-objects/src/apps/translations/ar.ts index afdf92accf8..150ab0690d4 100644 --- a/packages/platform-objects/src/apps/translations/ar.ts +++ b/packages/platform-objects/src/apps/translations/ar.ts @@ -38,7 +38,6 @@ export const ar: TranslationData = { navigation: { group_overview: { label: 'نظرة عامة' }, group_apps: { label: 'التطبيقات' }, - nav_packaged_actions: { label: 'الإجراءات المضمَّنة في الحزم' }, nav_marketplace_browse: { label: 'تصفح السوق' }, nav_marketplace_installed: { label: 'التطبيقات المثبّتة' }, nav_cloud_connection: { label: 'الاتصال السحابي' }, diff --git a/packages/platform-objects/src/apps/translations/de.source-hashes.ts b/packages/platform-objects/src/apps/translations/de.source-hashes.ts index 51e25aaf514..e3d76404dd5 100644 --- a/packages/platform-objects/src/apps/translations/de.source-hashes.ts +++ b/packages/platform-objects/src/apps/translations/de.source-hashes.ts @@ -73,7 +73,6 @@ export const deSourceHashes: Readonly> = { 'apps.setup.description': 'deacdfc679232a4a', 'apps.setup.navigation.group_overview.label': 'eebdbe1cc7b59cdf', 'apps.setup.navigation.group_apps.label': '699b367291abcbe6', - 'apps.setup.navigation.nav_packaged_actions.label': '0d86b11df972dff3', 'apps.setup.navigation.nav_marketplace_browse.label': '2afbe021f5419fdd', 'apps.setup.navigation.nav_marketplace_installed.label': '93bd5d458e05db60', 'apps.setup.navigation.nav_cloud_connection.label': '3a7caad0cb98e71d', diff --git a/packages/platform-objects/src/apps/translations/de.ts b/packages/platform-objects/src/apps/translations/de.ts index 29da9baf502..a3a700a2083 100644 --- a/packages/platform-objects/src/apps/translations/de.ts +++ b/packages/platform-objects/src/apps/translations/de.ts @@ -38,7 +38,6 @@ export const de: TranslationData = { navigation: { group_overview: { label: 'Übersicht' }, group_apps: { label: 'Apps' }, - nav_packaged_actions: { label: 'Aktionen aus Paketen' }, nav_marketplace_browse: { label: 'Marketplace durchsuchen' }, nav_marketplace_installed: { label: 'Installierte Apps' }, nav_cloud_connection: { label: 'Cloud-Verbindung' }, diff --git a/packages/platform-objects/src/apps/translations/en.ts b/packages/platform-objects/src/apps/translations/en.ts index d3840004000..ecaa20b6e75 100644 --- a/packages/platform-objects/src/apps/translations/en.ts +++ b/packages/platform-objects/src/apps/translations/en.ts @@ -73,7 +73,6 @@ export const en: TranslationData = { nav_connect_agent: { label: 'Connect an AI Assistant' }, // Apps / Marketplace - nav_packaged_actions: { label: 'Packaged Actions' }, nav_marketplace_browse: { label: 'Browse Marketplace' }, nav_marketplace_installed: { label: 'Installed Apps' }, nav_cloud_connection: { label: 'Cloud Connection' }, diff --git a/packages/platform-objects/src/apps/translations/es-ES.source-hashes.ts b/packages/platform-objects/src/apps/translations/es-ES.source-hashes.ts index dcae7f03bb9..b93bc8df93f 100644 --- a/packages/platform-objects/src/apps/translations/es-ES.source-hashes.ts +++ b/packages/platform-objects/src/apps/translations/es-ES.source-hashes.ts @@ -72,7 +72,6 @@ export const esESSourceHashes: Readonly> = { 'apps.setup.description': 'deacdfc679232a4a', 'apps.setup.navigation.group_overview.label': 'eebdbe1cc7b59cdf', 'apps.setup.navigation.group_apps.label': '699b367291abcbe6', - 'apps.setup.navigation.nav_packaged_actions.label': '0d86b11df972dff3', 'apps.setup.navigation.nav_marketplace_browse.label': '2afbe021f5419fdd', 'apps.setup.navigation.nav_marketplace_installed.label': '93bd5d458e05db60', 'apps.setup.navigation.nav_cloud_connection.label': '3a7caad0cb98e71d', diff --git a/packages/platform-objects/src/apps/translations/es-ES.ts b/packages/platform-objects/src/apps/translations/es-ES.ts index 341a49107d4..4a746033e30 100644 --- a/packages/platform-objects/src/apps/translations/es-ES.ts +++ b/packages/platform-objects/src/apps/translations/es-ES.ts @@ -38,7 +38,6 @@ export const esES: TranslationData = { navigation: { group_overview: { label: 'Resumen' }, group_apps: { label: 'Aplicaciones' }, - nav_packaged_actions: { label: 'Acciones empaquetadas' }, nav_marketplace_browse: { label: 'Explorar Marketplace' }, nav_marketplace_installed: { label: 'Aplicaciones instaladas' }, nav_cloud_connection: { label: 'Conexión a la nube' }, diff --git a/packages/platform-objects/src/apps/translations/fr.source-hashes.ts b/packages/platform-objects/src/apps/translations/fr.source-hashes.ts index b28c5a1ea6e..5302c2006b6 100644 --- a/packages/platform-objects/src/apps/translations/fr.source-hashes.ts +++ b/packages/platform-objects/src/apps/translations/fr.source-hashes.ts @@ -73,7 +73,6 @@ export const frSourceHashes: Readonly> = { 'apps.setup.description': 'deacdfc679232a4a', 'apps.setup.navigation.group_overview.label': 'eebdbe1cc7b59cdf', 'apps.setup.navigation.group_apps.label': '699b367291abcbe6', - 'apps.setup.navigation.nav_packaged_actions.label': '0d86b11df972dff3', 'apps.setup.navigation.nav_marketplace_browse.label': '2afbe021f5419fdd', 'apps.setup.navigation.nav_marketplace_installed.label': '93bd5d458e05db60', 'apps.setup.navigation.nav_cloud_connection.label': '3a7caad0cb98e71d', diff --git a/packages/platform-objects/src/apps/translations/fr.ts b/packages/platform-objects/src/apps/translations/fr.ts index 8281ac9297f..5c5cfb5374f 100644 --- a/packages/platform-objects/src/apps/translations/fr.ts +++ b/packages/platform-objects/src/apps/translations/fr.ts @@ -38,7 +38,6 @@ export const fr: TranslationData = { navigation: { group_overview: { label: 'Aperçu' }, group_apps: { label: 'Applications' }, - nav_packaged_actions: { label: 'Actions fournies par les packages' }, nav_marketplace_browse: { label: 'Parcourir la Marketplace' }, nav_marketplace_installed: { label: 'Applications installées' }, nav_cloud_connection: { label: 'Connexion au cloud' }, diff --git a/packages/platform-objects/src/apps/translations/ja-JP.source-hashes.ts b/packages/platform-objects/src/apps/translations/ja-JP.source-hashes.ts index 23142a1d9a8..9e3aed8ff52 100644 --- a/packages/platform-objects/src/apps/translations/ja-JP.source-hashes.ts +++ b/packages/platform-objects/src/apps/translations/ja-JP.source-hashes.ts @@ -72,7 +72,6 @@ export const jaJPSourceHashes: Readonly> = { 'apps.setup.description': 'deacdfc679232a4a', 'apps.setup.navigation.group_overview.label': 'eebdbe1cc7b59cdf', 'apps.setup.navigation.group_apps.label': '699b367291abcbe6', - 'apps.setup.navigation.nav_packaged_actions.label': '0d86b11df972dff3', 'apps.setup.navigation.nav_marketplace_browse.label': '2afbe021f5419fdd', 'apps.setup.navigation.nav_marketplace_installed.label': '93bd5d458e05db60', 'apps.setup.navigation.nav_cloud_connection.label': '3a7caad0cb98e71d', diff --git a/packages/platform-objects/src/apps/translations/ja-JP.ts b/packages/platform-objects/src/apps/translations/ja-JP.ts index 4989859a123..632a2e81284 100644 --- a/packages/platform-objects/src/apps/translations/ja-JP.ts +++ b/packages/platform-objects/src/apps/translations/ja-JP.ts @@ -38,7 +38,6 @@ export const jaJP: TranslationData = { navigation: { group_overview: { label: '概要' }, group_apps: { label: 'アプリ' }, - nav_packaged_actions: { label: 'パッケージアクション' }, nav_marketplace_browse: { label: 'マーケットプレイスを閲覧' }, nav_marketplace_installed: { label: 'インストール済みアプリ' }, nav_cloud_connection: { label: 'クラウド接続' }, diff --git a/packages/platform-objects/src/apps/translations/ko.source-hashes.ts b/packages/platform-objects/src/apps/translations/ko.source-hashes.ts index 44d60b1bebf..6a64bb69ff0 100644 --- a/packages/platform-objects/src/apps/translations/ko.source-hashes.ts +++ b/packages/platform-objects/src/apps/translations/ko.source-hashes.ts @@ -73,7 +73,6 @@ export const koSourceHashes: Readonly> = { 'apps.setup.description': 'deacdfc679232a4a', 'apps.setup.navigation.group_overview.label': 'eebdbe1cc7b59cdf', 'apps.setup.navigation.group_apps.label': '699b367291abcbe6', - 'apps.setup.navigation.nav_packaged_actions.label': '0d86b11df972dff3', 'apps.setup.navigation.nav_marketplace_browse.label': '2afbe021f5419fdd', 'apps.setup.navigation.nav_marketplace_installed.label': '93bd5d458e05db60', 'apps.setup.navigation.nav_cloud_connection.label': '3a7caad0cb98e71d', diff --git a/packages/platform-objects/src/apps/translations/ko.ts b/packages/platform-objects/src/apps/translations/ko.ts index 1c510c4db45..037bb24cb41 100644 --- a/packages/platform-objects/src/apps/translations/ko.ts +++ b/packages/platform-objects/src/apps/translations/ko.ts @@ -38,7 +38,6 @@ export const ko: TranslationData = { navigation: { group_overview: { label: '개요' }, group_apps: { label: '앱' }, - nav_packaged_actions: { label: '패키지 액션' }, nav_marketplace_browse: { label: '마켓플레이스 둘러보기' }, nav_marketplace_installed: { label: '설치된 앱' }, nav_cloud_connection: { label: '클라우드 연결' }, diff --git a/packages/platform-objects/src/apps/translations/pt-BR.source-hashes.ts b/packages/platform-objects/src/apps/translations/pt-BR.source-hashes.ts index 1f0fc650704..6cd46212750 100644 --- a/packages/platform-objects/src/apps/translations/pt-BR.source-hashes.ts +++ b/packages/platform-objects/src/apps/translations/pt-BR.source-hashes.ts @@ -73,7 +73,6 @@ export const ptBRSourceHashes: Readonly> = { 'apps.setup.description': 'deacdfc679232a4a', 'apps.setup.navigation.group_overview.label': 'eebdbe1cc7b59cdf', 'apps.setup.navigation.group_apps.label': '699b367291abcbe6', - 'apps.setup.navigation.nav_packaged_actions.label': '0d86b11df972dff3', 'apps.setup.navigation.nav_marketplace_browse.label': '2afbe021f5419fdd', 'apps.setup.navigation.nav_marketplace_installed.label': '93bd5d458e05db60', 'apps.setup.navigation.nav_cloud_connection.label': '3a7caad0cb98e71d', diff --git a/packages/platform-objects/src/apps/translations/pt-BR.ts b/packages/platform-objects/src/apps/translations/pt-BR.ts index f59a880f56c..e24082a8d81 100644 --- a/packages/platform-objects/src/apps/translations/pt-BR.ts +++ b/packages/platform-objects/src/apps/translations/pt-BR.ts @@ -38,7 +38,6 @@ export const ptBR: TranslationData = { navigation: { group_overview: { label: 'Visão geral' }, group_apps: { label: 'Aplicativos' }, - nav_packaged_actions: { label: 'Ações fornecidas por pacotes' }, nav_marketplace_browse: { label: 'Explorar o Marketplace' }, nav_marketplace_installed: { label: 'Aplicativos instalados' }, nav_cloud_connection: { label: 'Conexão com a nuvem' }, diff --git a/packages/platform-objects/src/apps/translations/ru.source-hashes.ts b/packages/platform-objects/src/apps/translations/ru.source-hashes.ts index bca0e15ba04..80446375c63 100644 --- a/packages/platform-objects/src/apps/translations/ru.source-hashes.ts +++ b/packages/platform-objects/src/apps/translations/ru.source-hashes.ts @@ -73,7 +73,6 @@ export const ruSourceHashes: Readonly> = { 'apps.setup.description': 'deacdfc679232a4a', 'apps.setup.navigation.group_overview.label': 'eebdbe1cc7b59cdf', 'apps.setup.navigation.group_apps.label': '699b367291abcbe6', - 'apps.setup.navigation.nav_packaged_actions.label': '0d86b11df972dff3', 'apps.setup.navigation.nav_marketplace_browse.label': '2afbe021f5419fdd', 'apps.setup.navigation.nav_marketplace_installed.label': '93bd5d458e05db60', 'apps.setup.navigation.nav_cloud_connection.label': '3a7caad0cb98e71d', diff --git a/packages/platform-objects/src/apps/translations/ru.ts b/packages/platform-objects/src/apps/translations/ru.ts index b4f43977ada..1daaf3fe7b2 100644 --- a/packages/platform-objects/src/apps/translations/ru.ts +++ b/packages/platform-objects/src/apps/translations/ru.ts @@ -38,7 +38,6 @@ export const ru: TranslationData = { navigation: { group_overview: { label: 'Обзор' }, group_apps: { label: 'Приложения' }, - nav_packaged_actions: { label: 'Действия из пакетов' }, nav_marketplace_browse: { label: 'Обзор Marketplace' }, nav_marketplace_installed: { label: 'Установленные приложения' }, nav_cloud_connection: { label: 'Подключение к облаку' }, diff --git a/packages/platform-objects/src/apps/translations/setup-nav-dead-key-tombstone.test.ts b/packages/platform-objects/src/apps/translations/setup-nav-dead-key-tombstone.test.ts index fea01e38a56..fac34672294 100644 --- a/packages/platform-objects/src/apps/translations/setup-nav-dead-key-tombstone.test.ts +++ b/packages/platform-objects/src/apps/translations/setup-nav-dead-key-tombstone.test.ts @@ -73,7 +73,15 @@ // are the whole claim. // nav_packaged_automation Setup › Packaged automation (ADR-0146 D11): its // flows half moved into Studio (D4), and its actions -// half is its own entry, `nav_packaged_actions`. +// half became its own entry, `nav_packaged_actions`. +// nav_packaged_actions Setup › Packaged Actions (objectstack#34724, the +// ADR-0146 D4 amendment of 2026-11-17): a packaged +// action's switch moved onto the action, in its app +// in Studio. Measured differently: the grep answers +// zero for `id: 'nav_packaged_actions'`, but the id +// is still spelled by this file, the retirement pin +// and the QA checklist, so the assertions below are +// the whole claim. // nav_audit_log_browser the console's audit browser (`audit:log`), which // `@objectstack/plugin-audit` now contributes under // `nav_audit_logs` ("Audit Log"), the id its @@ -126,6 +134,7 @@ const DEAD_SETUP_NAV_IDS = [ 'nav_device_codes', 'nav_jwks', 'nav_metadata', + 'nav_packaged_actions', 'nav_packaged_automation', 'nav_permission_sets', 'nav_positions', diff --git a/packages/platform-objects/src/apps/translations/zh-CN.source-hashes.ts b/packages/platform-objects/src/apps/translations/zh-CN.source-hashes.ts index a559ec3016b..6e8e88b5f71 100644 --- a/packages/platform-objects/src/apps/translations/zh-CN.source-hashes.ts +++ b/packages/platform-objects/src/apps/translations/zh-CN.source-hashes.ts @@ -72,7 +72,6 @@ export const zhCNSourceHashes: Readonly> = { 'apps.setup.description': 'deacdfc679232a4a', 'apps.setup.navigation.group_overview.label': 'eebdbe1cc7b59cdf', 'apps.setup.navigation.group_apps.label': '699b367291abcbe6', - 'apps.setup.navigation.nav_packaged_actions.label': '0d86b11df972dff3', 'apps.setup.navigation.nav_marketplace_browse.label': '2afbe021f5419fdd', 'apps.setup.navigation.nav_marketplace_installed.label': '93bd5d458e05db60', 'apps.setup.navigation.nav_cloud_connection.label': '3a7caad0cb98e71d', diff --git a/packages/platform-objects/src/apps/translations/zh-CN.ts b/packages/platform-objects/src/apps/translations/zh-CN.ts index bd94da4faa9..3f2519e2c27 100644 --- a/packages/platform-objects/src/apps/translations/zh-CN.ts +++ b/packages/platform-objects/src/apps/translations/zh-CN.ts @@ -38,7 +38,6 @@ export const zhCN: TranslationData = { navigation: { group_overview: { label: '总览' }, group_apps: { label: '应用' }, - nav_packaged_actions: { label: '打包动作' }, nav_marketplace_browse: { label: '浏览应用市场' }, nav_marketplace_installed: { label: '已安装应用' }, nav_cloud_connection: { label: '云连接' }, diff --git a/packages/platform-objects/src/apps/translations/zh-Hant.source-hashes.ts b/packages/platform-objects/src/apps/translations/zh-Hant.source-hashes.ts index b878361777d..8d85f88d02e 100644 --- a/packages/platform-objects/src/apps/translations/zh-Hant.source-hashes.ts +++ b/packages/platform-objects/src/apps/translations/zh-Hant.source-hashes.ts @@ -73,7 +73,6 @@ export const zhHantSourceHashes: Readonly> = { 'apps.setup.description': 'deacdfc679232a4a', 'apps.setup.navigation.group_overview.label': 'eebdbe1cc7b59cdf', 'apps.setup.navigation.group_apps.label': '699b367291abcbe6', - 'apps.setup.navigation.nav_packaged_actions.label': '0d86b11df972dff3', 'apps.setup.navigation.nav_marketplace_browse.label': '2afbe021f5419fdd', 'apps.setup.navigation.nav_marketplace_installed.label': '93bd5d458e05db60', 'apps.setup.navigation.nav_cloud_connection.label': '3a7caad0cb98e71d', diff --git a/packages/platform-objects/src/apps/translations/zh-Hant.ts b/packages/platform-objects/src/apps/translations/zh-Hant.ts index 387e1ebc926..1ae6b8da89d 100644 --- a/packages/platform-objects/src/apps/translations/zh-Hant.ts +++ b/packages/platform-objects/src/apps/translations/zh-Hant.ts @@ -38,7 +38,6 @@ export const zhHant: TranslationData = { navigation: { group_overview: { label: '總覽' }, group_apps: { label: '應用程式' }, - nav_packaged_actions: { label: '打包動作' }, nav_marketplace_browse: { label: '瀏覽應用程式市場' }, nav_marketplace_installed: { label: '已安裝應用程式' }, nav_cloud_connection: { label: '雲端連線' }, diff --git a/packages/platform-objects/src/system/sys-metadata-activation.object.test.ts b/packages/platform-objects/src/system/sys-metadata-activation.object.test.ts index 56d80fb7ef6..80bdc8933e5 100644 --- a/packages/platform-objects/src/system/sys-metadata-activation.object.test.ts +++ b/packages/platform-objects/src/system/sys-metadata-activation.object.test.ts @@ -201,13 +201,10 @@ describe('sys_metadata_activation — the ADR-0126 §4 activation ledger', () => ACCOUNT_APP, SETUP_NAV_CONTRIBUTIONS, ]); - // One mention is allowed, and it is not a surface: Packaged Actions' - // `visible` asks whether the member may READ the ledger (#33224), a - // permission question that no row, present or absent, changes. Nothing - // targets the object, and nothing else names it. - const audience = "current_user.can('sys_metadata_activation', 'read')"; - expect(shippedSurfaces.split(audience)).toHaveLength(2); - expect(shippedSurfaces.split(audience).join('')).not.toContain('sys_metadata_activation'); + // No mention at all. The one there was, Packaged Actions' `visible` + // (#33224, a read-permission question), retired with the entry + // (objectstack#34724): a packaged action's switch is in Studio now. + expect(shippedSurfaces).not.toContain('sys_metadata_activation'); }); }); }); diff --git a/packages/qa/dogfood/test/api-action-door-forward.dogfood.test.ts b/packages/qa/dogfood/test/api-action-door-forward.dogfood.test.ts index b344ffff89b..11dcff40f19 100644 --- a/packages/qa/dogfood/test/api-action-door-forward.dogfood.test.ts +++ b/packages/qa/dogfood/test/api-action-door-forward.dogfood.test.ts @@ -196,9 +196,13 @@ describe('[#27506] a same-origin api action is dispatched through the action doo expect(refused.json?.error?.code).toBe('ACTION_DISABLED'); // [#27842] The sentence is the end user's: it names where an administrator // turns the action back on, and no system table (the code is the machine half). + // [#34724, ruling 6944409840] ban_user is a platform (plugin-auth, scope + // `system`) action, which Studio offers no switch for, so the sentence + // names the activation door instead. const message = String(refused.json?.error?.message); expect(message).toMatch(/^This action is turned off for this deployment\. /); - expect(message).toContain('An administrator can turn it on again under Setup › Packaged Actions'); + expect(message).toContain('An administrator can turn it on again through the action activation API (POST /api/v1/actions/_activation/'); + expect(message).not.toContain('in its package in Studio'); expect(message).not.toContain('sys_metadata_activation'); expect(await isBanned(), 'a switched-off Ban User still banned — the #27506 defect').toBe(false); }, 120_000); diff --git a/packages/qa/dogfood/test/packaged-action-disabled-dispatch-live.dogfood.test.ts b/packages/qa/dogfood/test/packaged-action-disabled-dispatch-live.dogfood.test.ts index 29dedd38cd9..721b057274e 100644 --- a/packages/qa/dogfood/test/packaged-action-disabled-dispatch-live.dogfood.test.ts +++ b/packages/qa/dogfood/test/packaged-action-disabled-dispatch-live.dogfood.test.ts @@ -67,7 +67,7 @@ const activation = (object: string, action: string) => `/actions/_activation/${o */ function expectDisabledSentence(message: unknown, _action: string) { expect(String(message)).toMatch(/^This action is turned off for this deployment\. /); - expect(String(message)).toContain('An administrator can turn it on again under Setup › Packaged Actions'); + expect(String(message)).toContain('An administrator can turn it on again on the action in its package in Studio'); expect(String(message)).not.toContain(LEDGER); expect(String(message)).not.toMatch(/ADR-\d+/); } diff --git a/packages/runtime/src/domains/action-activation-dispatch.test.ts b/packages/runtime/src/domains/action-activation-dispatch.test.ts index 5a79991293d..9eb87a23755 100644 --- a/packages/runtime/src/domains/action-activation-dispatch.test.ts +++ b/packages/runtime/src/domains/action-activation-dispatch.test.ts @@ -27,6 +27,9 @@ import { describe, it, expect, vi } from 'vitest'; import type { AutomationResult } from '@objectstack/spec/contracts'; +// Paid at collection, not inside a case's clock (check:test-source-alias). +import '@objectstack/metadata'; + import { HttpDispatcher } from '../http-dispatcher.js'; import type { HttpProtocolContext } from '../http-dispatcher.js'; import { invokeBusinessAction, disabledActionRefusal } from '../action-execution.js'; @@ -142,7 +145,7 @@ describe('door 1 — REST `POST /actions/:object/:action`', () => { // The words are the contract here (they are what the toast reads), so // the first sentence is pinned, and the remedy beside it. expect(message.startsWith('This action is turned off for this deployment.')).toBe(true); - expect(message).toContain('An administrator can turn it on again under Setup › Packaged Actions'); + expect(message).toContain('An administrator can turn it on again on the action in its package in Studio'); // No system table, no ADR citation, no tracker number in what an end user reads. expect(message).not.toContain('sys_metadata_activation'); expect(message).not.toMatch(/ADR-\d+/); diff --git a/packages/services/service-automation/src/connector-credentials-ui.ts b/packages/services/service-automation/src/connector-credentials-ui.ts index da164ae5f21..0108a1cfd2b 100644 --- a/packages/services/service-automation/src/connector-credentials-ui.ts +++ b/packages/services/service-automation/src/connector-credentials-ui.ts @@ -8,8 +8,8 @@ * service, no entry). * * The page body is the console's `automation:connector-credentials` component - * (`@object-ui/app-shell`), the way Setup's packaged-actions entry names - * `automation:packaged-actions`. It reads `GET /api/v1/automation/connectors/credential-refs` + * (`@object-ui/app-shell`), named by registry key like every other + * framework-contributed Setup page. It reads `GET /api/v1/automation/connectors/credential-refs` * and writes through `PUT` / `DELETE …/credential-refs/:ref`; ⛔ no value ever * reaches it, since none of the three routes answers one. * diff --git a/packages/spec/src/api/protocol.zod.ts b/packages/spec/src/api/protocol.zod.ts index fba9e5beb28..d5ce545a9a6 100644 --- a/packages/spec/src/api/protocol.zod.ts +++ b/packages/spec/src/api/protocol.zod.ts @@ -791,7 +791,7 @@ export const GetMetaItemResponseSchema = lazySchema(() => z.object({ ), disabledActions: z.array(z.string()).optional().describe( 'The names in `item.actions` that this deployment\'s activation ledger switches off (an administrator ' - + 'turned them off under Setup › Packaged Actions): a call to any of them is refused 409 ' + + 'turned them off on the action, in its package in Studio): a call to any of them is refused 409 ' + '`ACTION_DISABLED`. Present only on an `object` read answered by a process whose data engine has an ' + 'activation ledger attached, and then `[]` when none of this object\'s actions is switched off. ' + 'Absent otherwise, and absence means no ledger answered, never that nothing is switched off. Unlike ' diff --git a/packages/types/src/packaged-item-turned-off.test.ts b/packages/types/src/packaged-item-turned-off.test.ts index 4909def07c3..4f1546371f5 100644 --- a/packages/types/src/packaged-item-turned-off.test.ts +++ b/packages/types/src/packaged-item-turned-off.test.ts @@ -4,10 +4,10 @@ import { describe, it, expect } from 'vitest'; import { describeTurnedOffPackagedItem } from './packaged-item-turned-off.js'; describe('describeTurnedOffPackagedItem — the one switched-off packaged item sentence (#27842 / #27966)', () => { - it('the action sentence is the one #27842 settled, byte for byte', () => { + it('the action sentence is the one #27842 settled, sending the reader to Studio (#34724), byte for byte', () => { expect(describeTurnedOffPackagedItem('action')).toBe( - 'This action is turned off for this deployment. An administrator can turn it on again under ' - + 'Setup › Packaged Actions, or you can use another action.', + 'This action is turned off for this deployment. An administrator can turn it on again ' + + 'on the action in its package in Studio, or you can use another action.', ); }); @@ -18,14 +18,31 @@ describe('describeTurnedOffPackagedItem — the one switched-off packaged item s ); }); - it.each(['action', 'flow'] as const)('the %s sentence names no system table and no ADR', (kind) => { - const message = describeTurnedOffPackagedItem(kind); + it('a platform action\'s sentence names the activation door, not Studio (#34724, ruling 6944409840)', () => { + expect(describeTurnedOffPackagedItem('action', { platform: true })).toBe( + 'This action is turned off for this deployment. An administrator can turn it on again ' + + 'through the action activation API (POST /api/v1/actions/_activation// with {"enabled": true}; ' + + "Studio has no switch for the platform's own actions), or you can use another action.", + ); + // An app's action, said explicitly, is the Studio sentence. + expect(describeTurnedOffPackagedItem('action', { platform: false })).toBe(describeTurnedOffPackagedItem('action')); + }); + + it('a flow has no platform variant: the option changes nothing', () => { + expect(describeTurnedOffPackagedItem('flow', { platform: true })).toBe(describeTurnedOffPackagedItem('flow')); + }); + + it.each([['action', false], ['action', true], ['flow', false]] as const)('the %s sentence (platform: %s) names no system table and no ADR', (kind, platform) => { + const message = describeTurnedOffPackagedItem(kind, { platform }); expect(message).not.toContain('sys_metadata_activation'); expect(message).not.toMatch(/ADR-\d+/); expect(message).not.toMatch(/#\d+/); }); - it.each(['action', 'flow'] as const)('the %s sentence does not send anyone to the retired Packaged automation page', (kind) => { - expect(describeTurnedOffPackagedItem(kind)).not.toContain('Packaged automation'); + it.each([['action', false], ['action', true], ['flow', false]] as const)('the %s sentence (platform: %s) does not send anyone to a retired Setup page', (kind, platform) => { + const message = describeTurnedOffPackagedItem(kind, { platform }); + expect(message).not.toContain('Packaged automation'); + expect(message).not.toContain('Packaged Actions'); + expect(message).not.toContain('Setup'); }); }); diff --git a/packages/types/src/packaged-item-turned-off.ts b/packages/types/src/packaged-item-turned-off.ts index eb5a5d2e3ce..3278b139eda 100644 --- a/packages/types/src/packaged-item-turned-off.ts +++ b/packages/types/src/packaged-item-turned-off.ts @@ -19,22 +19,31 @@ * on this package, so the one sentence adds no edge. * * The kinds differ in two places, and both follow where the switch is - * (ADR-0146 D4, D11). WHERE: an action's switch is on Setup's Packaged Actions - * page (the `nav_packaged_actions` entry); a flow's switch is on the flow, in - * its package's Automations in Studio. Setup's Packaged automation page, which - * held both, is retired, so neither sentence names it. MEANWHILE: flow clone is + * (ADR-0146 D4, amended 2026-11-17; D11). WHERE: an action's switch is on the + * action, in its package in Studio (the object's Actions view, or a standalone + * action's item page; objectstack#34724 retired Setup's Packaged Actions page, + * which held it); a flow's switch is on the flow, in its package's Automations + * in Studio. Neither retired Setup page is named. MEANWHILE: flow clone is * chartered (ADR-0126 §7.2: `POST /automation/:name/clone`), offered as New * similar on the same Studio flow, so the flow sentence offers a copy there. * Action-clone is not (§8 item 2), so the action sentence ⛔ never does: * recommending one would advertise machinery that does not exist. * + * A PLATFORM action (one a kernel package ships) has no switch in Studio + * (ADR-0146 D4 as amended: no switch anywhere), yet a ledger row written + * before Setup's page retired can still hold it off (maintainer ruling + * 6944409840: such rows stay in force). Its sentence therefore names the + * activation door itself, the one way left to turn it on again, rather than a + * Studio place that offers nothing. `platform` is the caller's verdict; it is + * read for an action only (a flow has no platform variant). + * * The item's name is not in the sentence: the caller named the item it asked * for, and a machine name read in a toast is not plain language. */ export type PackagedItemKind = 'action' | 'flow'; const WHERE: Record = { - action: 'under Setup › Packaged Actions', + action: 'on the action in its package in Studio', flow: "in its package's Automations in Studio", }; @@ -43,9 +52,23 @@ const MEANWHILE: Record = { flow: 'or copy it there under a new name', }; -export function describeTurnedOffPackagedItem(kind: PackagedItemKind): string { +/** Where a switched-off PLATFORM action is turned on again: the activation door, not Studio. */ +const WHERE_PLATFORM_ACTION = + 'through the action activation API (POST /api/v1/actions/_activation// with {"enabled": true}; ' + + 'Studio has no switch for the platform\'s own actions)'; + +export interface TurnedOffPackagedItemOptions { + /** The item is a platform (kernel-package) action. Ignored for a flow. */ + platform?: boolean; +} + +export function describeTurnedOffPackagedItem( + kind: PackagedItemKind, + options: TurnedOffPackagedItemOptions = {}, +): string { + const where = kind === 'action' && options.platform === true ? WHERE_PLATFORM_ACTION : WHERE[kind]; return ( `This ${kind} is turned off for this deployment. An administrator can turn it on again ` + - `${WHERE[kind]}, ${MEANWHILE[kind]}.` + `${where}, ${MEANWHILE[kind]}.` ); } diff --git a/ui/packages/app-shell/src/console/AppContent.tsx b/ui/packages/app-shell/src/console/AppContent.tsx index a7f2bae5226..b14cec26499 100644 --- a/ui/packages/app-shell/src/console/AppContent.tsx +++ b/ui/packages/app-shell/src/console/AppContent.tsx @@ -71,7 +71,12 @@ import { resolveSetupAppPath } from './ConsoleShell.js'; import { APP_ROUTE_METADATA_READS, collectRoutePaths, metadataReadsForAppRoute, type LazyMetadataType } from './appRouteMetadataReads.js'; import { enterAppBundle, readAppObjectScope } from './appObjectScope.js'; import { preferLocal } from '../utils/preferLocal.js'; -import { packagedAutomationStudioPath, setupMetadataRest, setupMetadataStudioPath } from '../views/studio-design/setupMetadataRedirect.js'; +import { + packagedActionsStudioPath, + packagedAutomationStudioPath, + setupMetadataRest, + setupMetadataStudioPath, +} from '../views/studio-design/setupMetadataRedirect.js'; import { NO_RECORD_DRAWERS_OPENING, NO_RECORD_PAGE_DRAWERS_OPEN, RecordDrawerOpeningProvider, RecordPageDrawerOpenProvider, useRecordFormOpensOverDrawers, type RecordDrawersOpening, type RecordPageDrawersOpen } from '../views/recordDrawerStack.js'; import { SkeletonDashboard, SkeletonDetail, SkeletonGrid } from '../skeletons/index.js'; @@ -1663,6 +1668,11 @@ export function AppContent({ extraRoutes, extraRoutesNoApp }: AppContentProps = Studio's Automations pillar. The static path outranks the `:ns/:name` route below it. */} } /> + {/* objectstack#34724 (ADR-0146 D4, amended 2026-11-17) — the + retired Setup › Packaged Actions page + (`automation:packaged-actions`): a bookmark opens Studio, + where a packaged action's switch is. */} + } /> } /> {/* Legacy: old metadata routes built before the REST-style nesting landed. Redirect to the new /metadata/:type/... shape. */} @@ -2102,6 +2112,16 @@ function PackagedAutomationRedirect() { return ; } +/** + * A bookmark of the retired Setup › Packaged Actions page (objectstack#34724) + * opens Studio: the named app's Data pillar, else the Studio landing + * (`packagedActionsStudioPath`). + */ +function PackagedActionsRedirect() { + const location = useLocation(); + return ; +} + /** * Translates pre-refactor metadata admin URLs * (`/apps/:app/component/metadata/resource/:name?type=:type`, diff --git a/ui/packages/app-shell/src/console/__tests__/AppContent.setupMetadataStudio-28578.test.tsx b/ui/packages/app-shell/src/console/__tests__/AppContent.setupMetadataStudio-28578.test.tsx index ffac8640029..336353ddd93 100644 --- a/ui/packages/app-shell/src/console/__tests__/AppContent.setupMetadataStudio-28578.test.tsx +++ b/ui/packages/app-shell/src/console/__tests__/AppContent.setupMetadataStudio-28578.test.tsx @@ -28,7 +28,9 @@ * One more retired Setup URL redirects here (ADR-0146 D11): a bookmark of * Setup › Packaged automation (`component/automation/packaged`) opens Studio's * Automations pillar for the package its `?package=` names, or the area's - * cross-package flow list when it names none. + * cross-package flow list when it names none. And objectstack#34724: a + * bookmark of Setup › Packaged Actions (`component/automation/packaged-actions`) + * opens the named app's Data pillar, or the Studio landing. * * The host's own aliases (`system/objects`, `system/metadata`, * `system/{roles,positions,permissions}`) are `apps/console`'s, pinned in @@ -42,6 +44,10 @@ import '@testing-library/jest-dom/vitest'; import { describe, it, expect, vi, beforeEach } from 'vitest'; import React from 'react'; +// The page reaches `celAuthoring`'s dynamic `@objectstack/lint` import; its +// first load is paid here, at collection, never inside a case's clock +// (`check:test-source-alias`). +import '@objectstack/lint'; import { render, screen } from '@testing-library/react'; import { MemoryRouter, Routes, Route, Navigate, useLocation, useParams } from 'react-router-dom'; @@ -220,13 +226,26 @@ describe('a bookmark of the retired Setup › Packaged automation page opens Stu }); it('control: another component ref still resolves through the component route, not Studio', async () => { - const chain = renderAt('/apps/setup/component/automation/packaged-actions'); + const chain = renderAt('/apps/setup/component/developer/packages'); await screen.findByTestId('console-layout'); - expect(chain).toEqual(['/apps/setup/component/automation/packaged-actions']); + expect(chain).toEqual(['/apps/setup/component/developer/packages']); expect(screen.queryByTestId('studio-probe')).not.toBeInTheDocument(); }); }); +describe('a bookmark of the retired Setup › Packaged Actions page opens Studio (objectstack#34724)', () => { + it.each([ + ['/apps/setup/component/automation/packaged-actions', '/studio'], + ['/apps/setup/component/automation/packaged-actions?package=crm', '/studio/crm/data?package=crm'], + ['/apps/crm/component/automation/packaged-actions?package=all', '/studio?package=all'], + ])('%s → %s, in one hop', async (from, to) => { + const chain = renderAt(from); + + expect(await screen.findByTestId('studio-probe')).toBeInTheDocument(); + expect(chain).toEqual([from, to]); + }); +}); + describe('the datasource pages keep their own shape', () => { it('a datasource create page renders in create mode', async () => { renderAt('/apps/setup/metadata/datasource/new'); diff --git a/ui/packages/app-shell/src/index.ts b/ui/packages/app-shell/src/index.ts index f59c95a2e7c..9cce5710344 100644 --- a/ui/packages/app-shell/src/index.ts +++ b/ui/packages/app-shell/src/index.ts @@ -599,12 +599,6 @@ export { StudioMetadataArea } from './views/studio-design/StudioMetadataArea.js' // onto Setup's metadata routes lands them in one hop through this. export { setupMetadataStudioPath } from './views/studio-design/setupMetadataRedirect.js'; -// Setup › Packaged actions (ADR-0126 §7.4) — on/off for the actions installed -// packages ship. Reached through the `automation:packaged-actions` component -// ref registered in `services/builtinComponents`; exported so a host app can -// compose the page directly. (Setup › Packaged automation retired with -// objectstack ADR-0146 D11: a packaged flow's switch and its copy are Studio's.) -export { PackagedActionsPage } from './views/setup/PackagedActionsPage.js'; // AI assistant bus — connects the metadata designers to the global chat. export { diff --git a/ui/packages/app-shell/src/services/builtinComponents.tsx b/ui/packages/app-shell/src/services/builtinComponents.tsx index 604676ab9ba..d2d22c7991f 100644 --- a/ui/packages/app-shell/src/services/builtinComponents.tsx +++ b/ui/packages/app-shell/src/services/builtinComponents.tsx @@ -107,8 +107,7 @@ const MetadataResourceRouter = lazy(() => * the `PackageFormDialog` and `PositionHoldersSection` chunks leave the closure. * * ⛔ It only defers anything while nothing else in the package's eager graph - * names the page module statically; the barrel's `PackagedActionsPage` - * re-export is tree-shaken today because the console imports no such name. + * names the page module statically. */ const PackagesPage = lazyPage('packages', () => import('../views/metadata-admin/PackagesPage.js').then((m) => m.PackagesPage), @@ -119,9 +118,6 @@ const PermissionMatrixEditPage = lazyPage('permission set', () => const MobileAppPage = lazyPage('mobile app', () => import('../console/mobile-app/MobileAppPage.js').then((m) => m.MobileAppPage), ); -const PackagedActionsPage = lazyPage('packaged actions', () => - import('../views/setup/PackagedActionsPage.js').then((m) => m.PackagedActionsPage), -); const ConnectorCredentialsPage = lazyPage('connector credentials', () => import('../views/setup/ConnectorCredentialsPage.js').then((m) => m.ConnectorCredentialsPage), ); @@ -201,22 +197,6 @@ registerAppComponent({ component: MobileAppPage, }); -/** - * ADR-0126 §7.4 — the Setup page for the actions installed packages ship: - * on/off for this deployment. Contributed the way every other framework-owned - * Setup surface is, by ref rather than by route, so the Setup app's navigation - * names `automation:packaged-actions` and `ComponentNavView` resolves it. - * objectstack ADR-0146 D4 keeps the action switch in Setup; the packaged - * FLOWS' page (`automation:packaged`) retired with D11, its switch and its - * clone being Studio's. - */ -registerAppComponent({ - ref: 'automation:packaged-actions', - label: 'Packaged Actions', - source: '@object-ui/app-shell', - component: PackagedActionsPage, -}); - /** * Setup → Integrations → Connector Credentials (ruling A on objectstack#27230). * The entry naming this ref is contributed by the automation service's UI diff --git a/ui/packages/app-shell/src/views/metadata-admin/ResourceEditPage.actionLedgerSwitch-34724.test.tsx b/ui/packages/app-shell/src/views/metadata-admin/ResourceEditPage.actionLedgerSwitch-34724.test.tsx new file mode 100644 index 00000000000..e252eb198ec --- /dev/null +++ b/ui/packages/app-shell/src/views/metadata-admin/ResourceEditPage.actionLedgerSwitch-34724.test.tsx @@ -0,0 +1,168 @@ +// Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license. + +/** + * objectstack#34724 (ADR-0146 D4 as amended 2026-11-17) — a standalone + * `action` item of a read-only app package carries the activation ledger's + * switch on its page in Studio's "All metadata" area, the one the object's + * Actions view draws for an embedded action (`ObjectActionsPanel.ledgerSwitch-34724.test.tsx` + * pins its readings, gate and refusals; this file pins the item page's mount + * and the object segment the flip addresses). + * + * Stubbed: the metadata client and the network. The page and the switch are real. + */ + +import '@testing-library/jest-dom/vitest'; +import * as React from 'react'; +// The page reaches `celAuthoring`'s dynamic `@objectstack/lint` import; its +// first load is paid here, at collection, never inside a case's clock +// (`check:test-source-alias`). +import '@objectstack/lint'; +import { describe, it, expect, vi, afterEach, beforeEach } from 'vitest'; +import { render, screen, cleanup, fireEvent, waitFor } from '@testing-library/react'; +import { MemoryRouter } from 'react-router-dom'; +import { MetadataAreaHostContext, type MetadataAreaHost } from './metadataAreaHost'; + +let layered: Record = {}; + +const client = { + list: vi.fn(async () => []), + listDrafts: vi.fn(async () => []), + get: vi.fn(async () => null), + getDraft: vi.fn(async () => null), + references: vi.fn(async () => []), + layered: vi.fn(async () => layered), + saveDraft: vi.fn(async () => ({})), + save: vi.fn(async () => ({})), +}; + +vi.mock('./useMetadata', async (importOriginal) => ({ + ...(await importOriginal>()), + useMetadataClient: () => client, + useMetadataTypes: () => ({ + loading: false, + error: null, + entries: [{ type: 'action', label: 'Action', domain: 'ui', allowEnvironmentOverlay: false, allowRuntimeCreate: true }], + }), +})); +vi.mock('./i18n', async (importOriginal) => ({ + ...(await importOriginal>()), + useMetadataLocale: () => 'en-US', +})); +vi.mock('../../hooks/useCanAuthorMetadata', async (importOriginal) => ({ + ...(await importOriginal>()), + useCanAuthorMetadata: () => true, + useCanReadAuthoringTrail: () => false, +})); +vi.mock('../../hooks/useTenancyPosture', async (importOriginal) => ({ + ...(await importOriginal>()), + useTenancyPosture: () => 'single', +})); + +const packageEntries = vi.hoisted(() => ({ + current: [] as Array<{ id: string; name: string; writable: boolean; namespace: string; kernel?: true }>, +})); +vi.mock('../studio-design/packages-io', async (importOriginal) => ({ + ...(await importOriginal>()), + fetchPackages: vi.fn(async () => packageEntries.current), +})); + +const toasts = vi.hoisted(() => ({ success: vi.fn(), error: vi.fn(), info: vi.fn(), warning: vi.fn() })); +vi.mock('sonner', () => ({ toast: toasts })); + +const posts: Array<{ url: string; body?: string }> = []; + +import { MetadataResourceEditPage } from './ResourceEditPage'; +import { fetchPackages } from '../studio-design/packages-io'; + +const APP = 'com.example.showcase'; +const KERNEL = 'com.objectstack.platform-objects'; + +const hostOf = (packageId: string, readOnly = true): MetadataAreaHost => ({ + packageId, + readOnly, + basePath: `/studio/${packageId}/metadata`, +}); + +beforeEach(() => { + layered = { + effective: { name: 'send_reminder', label: 'Send reminder', objectName: 'showcase_task', type: 'script', target: 'send_reminder' }, + code: null, + overlay: null, + editable: false, + deletable: false, + }; + packageEntries.current = [ + { id: APP, name: 'Showcase', writable: false, namespace: 'showcase' }, + { id: KERNEL, name: 'Platform objects', writable: false, namespace: 'sys', kernel: true }, + ]; + posts.length = 0; + toasts.success.mockClear(); + vi.stubGlobal( + 'fetch', + vi.fn(async (url: string, init?: RequestInit) => { + const method = init?.method ?? 'GET'; + const json = (status: number, body: unknown) => + new Response(JSON.stringify(body), { status, headers: { 'Content-Type': 'application/json' } }); + if (method === 'GET' && String(url).startsWith('/api/v1/data/sys_metadata_activation')) { + return json(200, { object: 'sys_metadata_activation', records: [], hasMore: false }); + } + if (method === 'POST' && String(url).startsWith('/api/v1/actions/_activation/')) { + posts.push({ url: String(url), body: init?.body as string | undefined }); + return json(200, { success: true, data: { enabled: JSON.parse(String(init?.body ?? '{}')).enabled } }); + } + return json(404, { success: false, error: { message: `unexpected ${method} ${url}` } }); + }), + ); +}); + +afterEach(() => { + cleanup(); + vi.unstubAllGlobals(); + vi.mocked(fetchPackages).mockClear(); +}); + +function openItem(host: MetadataAreaHost, name = 'send_reminder') { + render( + + + + + , + ); +} + +describe("a standalone action's item page carries the ledger switch (objectstack#34724)", () => { + it('on a read-only app package: the switch, and a flip addressed to the action\'s object', async () => { + openItem(hostOf(APP)); + const sw = await screen.findByTestId('action-ledger-switch'); + expect(sw).toHaveAttribute('aria-checked', 'true'); + fireEvent.click(sw); + await waitFor(() => expect(screen.getByTestId('action-ledger-switch')).toHaveAttribute('aria-checked', 'false')); + expect(posts).toEqual([{ url: '/api/v1/actions/_activation/showcase_task/send_reminder', body: '{"enabled":false}' }]); + expect(toasts.success).toHaveBeenCalledWith('"Send reminder" is switched off for this deployment.'); + }); + + it('an object-less action is addressed under `global`, the door\'s own spelling', async () => { + layered = { ...layered, effective: { name: 'open_help', label: 'Open help', type: 'url', target: 'https://example.com' } }; + openItem(hostOf(APP), 'open_help'); + fireEvent.click(await screen.findByTestId('action-ledger-switch')); + await waitFor(() => expect(posts).toHaveLength(1)); + expect(posts[0].url).toBe('/api/v1/actions/_activation/global/open_help'); + }); + + it('a platform (kernel) package\'s action carries no switch', async () => { + openItem(hostOf(KERNEL)); + await screen.findByTestId('package-readonly-banner'); + await waitFor(() => expect(vi.mocked(fetchPackages)).toHaveBeenCalled()); + expect(screen.queryByTestId('action-ledger-switch')).toBeNull(); + }); + + it('a writable package\'s action is edited, not switched: no switch', async () => { + layered = { ...layered, editable: true, deletable: true }; + openItem(hostOf('com.acme.mine', false)); + // Control: the page rendered the item. + expect(await screen.findAllByText('send_reminder')).not.toHaveLength(0); + expect(screen.queryByTestId('action-ledger-switch')).toBeNull(); + expect(vi.mocked(fetchPackages)).not.toHaveBeenCalled(); + }); +}); diff --git a/ui/packages/app-shell/src/views/metadata-admin/ResourceEditPage.tsx b/ui/packages/app-shell/src/views/metadata-admin/ResourceEditPage.tsx index ced68c5de4e..96979aef962 100644 --- a/ui/packages/app-shell/src/views/metadata-admin/ResourceEditPage.tsx +++ b/ui/packages/app-shell/src/views/metadata-admin/ResourceEditPage.tsx @@ -166,6 +166,9 @@ import { PositionHoldersSection } from './PositionHoldersSection.js'; import { PositionPermissionSetsSection } from './PositionPermissionSetsSection.js'; import { PositionHoldersSetupLink } from './SetupAssignmentsLink.js'; import { CatalogItemActiveSwitch } from './CatalogActiveSwitch.js'; +import { FlowLedgerSwitch } from '../studio-design/FlowLedgerSwitch.js'; +import { useActionLedger } from '../setup/packagedActionLedger.js'; +import { standaloneActionObjectName } from '../setup/packagedActions.js'; import { useMetadataAreaHost } from './metadataAreaHost.js'; import { declarationOnlyAuthoredObject } from './sharing-rule-catalog.js'; import { useRegisterUnsavedEdits } from '../../chrome/unsavedEdits.js'; @@ -201,6 +204,77 @@ function catalogActiveSection(type: string): React.ComponentType>; + locale: string; +}) { + const ledger = useActionLedger(packageId); + const objectName = standaloneActionObjectName(draft); + if (ledger.loadError) { + return ( +

+ {tFormat('engine.studio.actions.ledger.loadFailed', locale, { message: ledger.loadError })} +

+ ); + } + if (!ledger.offered) return null; + const enabled = ledger.enabledOf(name); + const label = typeof draft.label === 'string' && draft.label ? draft.label : name; + const refusal = ledger.refusalOf(objectName, name); + return ( +
+
+ + void ledger + .toggle(objectName, name, { + http: (status) => tFormat('engine.studio.auto.ledger.toggleFailedHttp', locale, { status }), + network: t('engine.studio.auto.ledger.toggleFailed', locale), + }) + .then((now) => { + if (now === null) return; + toast.success( + tFormat(now ? 'engine.studio.auto.ledger.switchedOn' : 'engine.studio.auto.ledger.switchedOff', locale, { + label, + }), + ); + }) + } + /> +
+ {refusal && ( +

+ {refusal} +

+ )} +
+ ); +} + /** * objectstack ADR-0146 D1/D7 (#28561) — the same sections under Studio's "All * metadata" area, which draws no assignment: who holds a position is Setup's @@ -3186,6 +3260,9 @@ function MetadataResourceEditPageImpl({ {t('engine.studio.pkg.readonlyHint', locale)} )} + {hostReadOnly && !createMode && type === 'action' && areaHost?.packageId && ( + + )} {readOnly && !hostReadOnly && !isLocked && !canAuthor && !walledDeciding && !declarationOnly && (
{ - // The section loads its lists on mount. Empty answers are enough: what this - // file measures is that the route resolves to the page at all. - vi.stubGlobal( - 'fetch', - vi.fn(async () => ({ ok: true, status: 200, json: async () => ({ success: true, data: [] }) }) as unknown as Response), - ); -}); - -afterEach(() => { - cleanup(); - vi.unstubAllGlobals(); -}); - -describe('the packaged-actions Setup nav contribution', () => { - it('registers the ref, owned by app-shell', () => { - const entry = getAppComponent(REF); - expect(entry).toBeDefined(); - expect(entry?.source).toBe('@object-ui/app-shell'); - }); - - it('addresses component/automation/packaged-actions', () => { - expect(componentRefToUrlSegments(REF)).toEqual(['automation', 'packaged-actions']); - }); - - it('mounts the page through the component route the ref builds, under one heading', async () => { - const url = `/apps/setup/component/${componentRefToUrlSegments(REF).join('/')}`; - - render( - - - } /> - - , - ); - - expect(await screen.findByRole('heading', { name: 'Packaged actions' })).toBeInTheDocument(); - // The page header names the page; the section does not name it twice. - expect(screen.getAllByRole('heading', { name: 'Packaged actions' })).toHaveLength(1); - expect(await screen.findByTestId('packaged-actions-section')).toBeInTheDocument(); - // The "Component not registered" empty state is what an unresolved ref - // renders; its absence is the other half of the assertion above. - expect(screen.queryByText('Component not registered')).toBeNull(); - }); - - it('the retired `automation:packaged` key resolves to nothing (ADR-0146 D11)', () => { - expect(getAppComponent('automation:packaged')).toBeUndefined(); - }); -}); diff --git a/ui/packages/app-shell/src/views/setup/PackagedActionsPage.tsx b/ui/packages/app-shell/src/views/setup/PackagedActionsPage.tsx deleted file mode 100644 index 897bbe9dad5..00000000000 --- a/ui/packages/app-shell/src/views/setup/PackagedActionsPage.tsx +++ /dev/null @@ -1,52 +0,0 @@ -// Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license. - -/** - * Setup › Packaged actions — on/off for this deployment, per action an - * installed package ships (ADR-0126 §7.4: "Studio keeps the editing; Setup - * gets the operational state"). - * - * The page is what stayed in Setup of Setup › Packaged automation. objectstack - * ADR-0146 D4 moved the packaged FLOW's switch onto the flow's item in Studio - * (the Automations pillar's ledger switch), and its clone became Studio's New - * similar, so D11 retired that page; D4 keeps the ACTION switch where it is, - * and no card of that epic moves it. So the actions section is this page, as - * it was, under the page header that names it. The section reads and writes - * through its own doors (`PackagedActionsSection.tsx` says which, and why each - * refusal is shown verbatim); the header's Refresh re-reads it. - * - * Reached through the `automation:packaged-actions` component ref registered - * in `services/builtinComponents`; the Setup navigation names that ref - * (`nav_packaged_actions`, platform-objects). - */ - -import * as React from 'react'; -import { Zap } from 'lucide-react'; -import { useObjectTranslation } from '@object-ui/i18n'; -import { PackagedActionsSection } from './PackagedActionsSection.js'; -import { PageHeader } from '../../layout/PageHeader.js'; - -export function PackagedActionsPage() { - const { t } = useObjectTranslation(); - const [nonce, setNonce] = React.useState(0); - return ( -
- } - refresh={{ - onRefresh: () => setNonce((n) => n + 1), - label: t('packagedAutomation.refresh', { defaultValue: 'Refresh' }), - }} - /> -
- -
-
- ); -} - -export default PackagedActionsPage; diff --git a/ui/packages/app-shell/src/views/setup/PackagedActionsSection.test.tsx b/ui/packages/app-shell/src/views/setup/PackagedActionsSection.test.tsx deleted file mode 100644 index 8adec8b97b8..00000000000 --- a/ui/packages/app-shell/src/views/setup/PackagedActionsSection.test.tsx +++ /dev/null @@ -1,613 +0,0 @@ -// Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license. - -/** - * Setup › Packaged automation, the packaged-ACTIONS section (ADR-0126 §8 - * item 2, amendment ruling 3) — behaviour. - * - * Five properties, in the order the section exercises them: - * - * 1. **state render** — a packaged action is ON unless the ledger says - * otherwise, and absence of a row is the ordinary stock-boot state rather - * than a missing fact. The scoping and ledger rules themselves live in - * `packagedActions.ts` and are measured directly in `packagedActions.test.ts`; - * what is checked here is that the rendered section applies them. - * 2. **round-trip** — flipping the switch calls the L6 activation door with - * the requested state, at the `/` path, with EXACTLY the - * one key the body declares — and the shown state follows the SERVER's - * answer, not the click. - * 3. **refusals, verbatim** — the three shapes this section must relay: the - * §5 operator gate (403 `PERMISSION_DENIED`), the ambiguous-name refusal - * (409 `RESOURCE_CONFLICT`, which NAMES the objects) and the no-ledger - * outage (503 `SERVICE_UNAVAILABLE`). Each is asserted as the exact - * server string; all three are transcribed character-for-character from - * the runtime's own message builders, and what is under test is that the - * section renders what it was sent, unedited. - * 4. **no clone** — ruling 3 charters the switch and nothing else, so the - * section offers no clone control at all. The flows section beside it - * keeps its own; this asserts the ABSENCE here, which is the half a - * "make the two sections consistent" change would quietly undo. - * 5. **no ancestry** — the withdrawn §9 shapes are absent, including when a - * response carries one. Pinning the rule at the RENDERER and not only at - * the wire is the point: a response field is the cheapest place for - * ancestry to reappear. - */ - -import '@testing-library/jest-dom/vitest'; -import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'; -import { cleanup, fireEvent, render, screen, waitFor, within } from '@testing-library/react'; -import React from 'react'; - -import { toast } from 'sonner'; -import { createI18n, I18nProvider } from '@object-ui/i18n'; -import { PackagedActionsSection } from './PackagedActionsSection'; - -vi.mock('sonner', () => ({ toast: { success: vi.fn() } })); - -/* -------------------------------------------------------------------------- */ -/* The server's own refusal strings */ -/* -------------------------------------------------------------------------- */ - -/** - * `refuseUngrantedActivationWrite` with `ACTION_ACTIVATION_SUBJECT` - * (`@objectstack/runtime`, `domains/activation-gate.ts`) for the `group` - * posture. Transcribed exactly: the clause naming the posture AND the one - * naming the sanctioned path are both load-bearing. - * - * ⚠️ The remedy clause is the ACTION one, and it deliberately does not say - * "clone": the gate carries a per-door remedy sentence precisely because - * action-clone is unchartered, and recommending one would advertise machinery - * that does not exist. A client that reworded this would put it back. - */ -const POSTURE_REFUSAL = - 'Enabling or disabling a packaged action writes an INSTALL-WIDE activation row, and this deployment runs ' + - "the 'group' tenancy posture, where that reaches every organization. It requires the platform operator " + - '(ADR-0126 §5) — an organization administrator cannot flip an install-wide switch. To switch a packaged ' + - 'action off for this installation, ask your platform operator; authoring your own action alongside it ' + - 'stays open to you.'; - -/** - * `refuseAmbiguousActionActivation` (`@objectstack/runtime`, `domains/actions.ts`). - * The OBJECT NAMES are the whole value of this refusal — nothing on the client - * can reconstruct which objects a machine name collides across. - */ -const AMBIGUITY_REFUSAL = - "Action 'export' is declared on 2 objects ('account', 'contact'), and the activation ledger addresses an " + - 'action by its machine name (ADR-0126 §4) — one row would switch every one of them, not just the one on ' + - "'account'. Refusing rather than changing artifacts you did not name. Give the actions distinct machine " + - 'names, or leave them armed.'; - -/** - * The engine's own 503, relayed by the door's `catch` arm: the activation - * ledger is not attached on this deployment, so nothing can be made durable. - * An outage is not a verdict about the action, and the sentence is the - * server's to phrase. - */ -const NO_LEDGER_REFUSAL = - 'No activation ledger is attached to this engine, so a packaged action cannot be switched off durably ' + - '(ADR-0126 §4). Refusing rather than reporting a switch that would not survive a restart.'; - -/* -------------------------------------------------------------------------- */ -/* Fake server */ -/* -------------------------------------------------------------------------- */ - -interface Fixture { - /** `GET /meta/object` items. */ - objects: Array>; - /** `GET /meta/action` items. */ - standalone: Array>; - /** `sys_metadata_activation` rows. */ - ledger: Array>; - /** Extra keys spliced into the ledger list response (e.g. `hasMore`). */ - ledgerExtra: Record; - /** Queued answers for `POST /actions/_activation/…`, in call order. */ - flip: Array<{ status: number; body: unknown }>; -} - -let fixture: Fixture; -let calls: Array<{ url: string; method: string; body?: unknown }>; - -function response(status: number, body: unknown): Response { - return { - ok: status >= 200 && status < 300, - status, - json: async () => body, - } as unknown as Response; -} - -/** ADR-0112 error envelope, as the runtime's `deps.error` puts it on the wire. */ -function errorEnvelope(code: string, message: string) { - return { success: false, error: { code, message } }; -} - -/** A packaged object with embedded action declarations. */ -function packagedObject(name: string, actions: Array>) { - return { name, label: name, actions, _packageId: 'com.objectstack.crm', _provenance: 'package' }; -} - -/** One install-level `sys_metadata_activation` row. */ -function ledgerRow(name: string, active: boolean) { - return { - metadata_type: 'action', - name, - package_id: 'com.objectstack.crm', - organization_id: null, - active, - }; -} - -beforeEach(() => { - calls = []; - fixture = { - objects: [ - packagedObject('account', [ - { name: 'send_invoice', label: 'Send invoice' }, - { name: 'archive_account', label: 'Archive account' }, - ]), - ], - standalone: [], - ledger: [], - ledgerExtra: {}, - flip: [], - }; - - vi.stubGlobal( - 'fetch', - vi.fn(async (input: RequestInfo | URL, init?: RequestInit) => { - const url = String(input); - const method = (init?.method ?? 'GET').toUpperCase(); - const body = init?.body ? JSON.parse(String(init.body)) : undefined; - calls.push({ url, method, body }); - - if (url.includes('/actions/_activation/')) { - const next = fixture.flip.shift(); - if (next) return response(next.status, next.body); - const enabled = (body as { enabled?: boolean } | undefined)?.enabled ?? true; - const [objectName, name] = url.split('/actions/_activation/')[1].split('/').map(decodeURIComponent); - // The server is the authority on what the state became — mirror it. - return response(200, { success: true, data: { name, objectName, enabled } }); - } - if (url.includes('/meta/object')) { - return response(200, { items: fixture.objects }); - } - if (url.includes('/meta/action')) { - return response(200, { items: fixture.standalone }); - } - if (url.includes('/data/sys_metadata_activation')) { - return response(200, { - success: true, - data: { - object: 'sys_metadata_activation', - records: fixture.ledger, - ...fixture.ledgerExtra, - }, - }); - } - throw new Error(`unexpected fetch: ${method} ${url}`); - }), - ); -}); - -afterEach(() => { - cleanup(); - vi.unstubAllGlobals(); -}); - -/** Render and wait for the first list paint. */ -async function renderSection() { - render(); - await screen.findByText('Send invoice'); -} - -const flipCalls = () => calls.filter((c) => c.url.includes('/actions/_activation/')); - -/* -------------------------------------------------------------------------- */ -/* 1) State render */ -/* -------------------------------------------------------------------------- */ - -describe('activation state as the ledger reports it', () => { - it('shows a packaged action as ON when the ledger holds no row for it', async () => { - await renderSection(); - expect(screen.getByRole('switch', { name: 'Activation for Send invoice on account' })).toBeChecked(); - expect( - screen.getByRole('switch', { name: 'Activation for Archive account on account' }), - ).toBeChecked(); - }); - - it('shows an action the ledger disabled as OFF, without any further ceremony', async () => { - fixture.ledger = [ledgerRow('send_invoice', false)]; - await renderSection(); - - expect( - screen.getByRole('switch', { name: 'Activation for Send invoice on account' }), - ).not.toBeChecked(); - // Its sibling, which has no row, is unaffected. - expect( - screen.getByRole('switch', { name: 'Activation for Archive account on account' }), - ).toBeChecked(); - }); - - it('leaves a TENANT-authored action off the section', async () => { - // A tenant overlay bound to a package carries a real package id, so only - // the provenance clause keeps it out (the cloud#970 counterexample). - fixture.objects = [ - ...fixture.objects, - { - name: 'my_object', - label: 'Mine', - _packageId: 'app.crm', - _provenance: 'org', - actions: [{ name: 'my_action', label: 'My action' }], - }, - ]; - await renderSection(); - expect(screen.queryByText('My action')).toBeNull(); - }); - - it('refuses to render a TRUNCATED ledger page rather than show a stale ON', async () => { - // A dropped row reads as "active", so a partial ledger would show a - // switched-off action as armed — the one direction this section must not - // fail in. - fixture.ledger = [ledgerRow('send_invoice', false)]; - fixture.ledgerExtra = { hasMore: true }; - render(); - - expect(await screen.findByRole('alert')).toHaveTextContent(/refusing to show a partial ledger/i); - expect(screen.queryByRole('switch')).toBeNull(); - }); -}); - -/* -------------------------------------------------------------------------- */ -/* 2) Activation round-trip */ -/* -------------------------------------------------------------------------- */ - -/** - * Switching a packaged action OFF asks a confirm first (objectstack#27521 row - * 20): click its switch, then the confirm. Switching one ON runs at once. - */ -async function switchOff(name: string): Promise { - fireEvent.click(screen.getByRole('switch', { name })); - fireEvent.click(await screen.findByTestId('packaged-action-off-confirm')); -} - -describe('activation round-trip', () => { - it('disables and re-enables a packaged action, showing what the server reports', async () => { - await renderSection(); - - const invoice = screen.getByRole('switch', { name: 'Activation for Send invoice on account' }); - expect(invoice).toBeChecked(); - - await switchOff('Activation for Send invoice on account'); - await waitFor(() => expect(flipCalls()).toHaveLength(1)); - expect(flipCalls()[0].method).toBe('POST'); - expect(flipCalls()[0].url).toContain('/actions/_activation/account/send_invoice'); - // ⛔ EXACTLY the one key the activation body declares — the door refuses - // unknown keys by name, and `{"enable": false}` (one letter off) is the - // #3899 shape that ENABLED an artifact and answered 200. - expect(flipCalls()[0].body).toEqual({ enabled: false }); - await waitFor(() => - expect( - screen.getByRole('switch', { name: 'Activation for Send invoice on account' }), - ).not.toBeChecked(), - ); - - fireEvent.click(screen.getByRole('switch', { name: 'Activation for Send invoice on account' })); - await waitFor(() => expect(flipCalls()).toHaveLength(2)); - expect(flipCalls()[1].body).toEqual({ enabled: true }); - await waitFor(() => - expect( - screen.getByRole('switch', { name: 'Activation for Send invoice on account' }), - ).toBeChecked(), - ); - }); - - it('moves only the flipped row, even when a sibling shares the object', async () => { - await renderSection(); - - await switchOff('Activation for Send invoice on account'); - await waitFor(() => - expect( - screen.getByRole('switch', { name: 'Activation for Send invoice on account' }), - ).not.toBeChecked(), - ); - expect( - screen.getByRole('switch', { name: 'Activation for Archive account on account' }), - ).toBeChecked(); - }); - - it('addresses an object-less action through the `global` segment', async () => { - fixture.objects = []; - fixture.standalone = [ - { name: 'nightly_sync', label: 'Nightly sync', _packageId: 'com.objectstack.crm', _provenance: 'package' }, - ]; - render(); - await screen.findByText('Nightly sync'); - - await switchOff('Activation for Nightly sync on global'); - await waitFor(() => expect(flipCalls()).toHaveLength(1)); - expect(flipCalls()[0].url).toContain('/actions/_activation/global/nightly_sync'); - }); -}); - -/* -------------------------------------------------------------------------- */ -/* 3) Refusals, verbatim */ -/* -------------------------------------------------------------------------- */ - -describe('server refusals reach the operator verbatim', () => { - it('renders the §5 posture gate refusal (403 PERMISSION_DENIED) unedited', async () => { - fixture.flip = [{ status: 403, body: errorEnvelope('PERMISSION_DENIED', POSTURE_REFUSAL) }]; - await renderSection(); - - await switchOff('Activation for Send invoice on account'); - - const shown = await screen.findByText(POSTURE_REFUSAL); - expect(shown).toBeInTheDocument(); - // The half a summarising client would drop: what the refused admin can do. - expect(shown.textContent).toContain('ask your platform operator'); - // The refused flip did not move the shown state. - expect(screen.getByRole('switch', { name: 'Activation for Send invoice on account' })).toBeChecked(); - // ⛔ And it was not retried. - expect(flipCalls()).toHaveLength(1); - }); - - it('renders the ambiguous-name refusal (409 RESOURCE_CONFLICT) with its named objects', async () => { - fixture.objects = [ - packagedObject('account', [{ name: 'export', label: 'Export' }]), - packagedObject('contact', [{ name: 'export', label: 'Export' }]), - ]; - fixture.flip = [{ status: 409, body: errorEnvelope('RESOURCE_CONFLICT', AMBIGUITY_REFUSAL) }]; - render(); - await screen.findByRole('switch', { name: 'Activation for Export on account' }); - - // Both rows are listed — the section does not pre-empt the server's - // conflict with a client-side guess about which one is "real". - expect(screen.getByRole('switch', { name: 'Activation for Export on contact' })).toBeInTheDocument(); - - await switchOff('Activation for Export on account'); - - const shown = await screen.findByText(AMBIGUITY_REFUSAL); - expect(shown).toBeInTheDocument(); - // The object names survive — nothing on the client could reconstruct them. - expect(shown.textContent).toContain("('account', 'contact')"); - }); - - it('renders the no-ledger outage (503 SERVICE_UNAVAILABLE) unedited', async () => { - fixture.flip = [{ status: 503, body: errorEnvelope('SERVICE_UNAVAILABLE', NO_LEDGER_REFUSAL) }]; - await renderSection(); - - await switchOff('Activation for Send invoice on account'); - - expect(await screen.findByText(NO_LEDGER_REFUSAL)).toBeInTheDocument(); - // An outage is not a verdict, and it is not a hiccup to paper over either: - // one attempt, no retry loop, and the state stays where the server left it. - expect(flipCalls()).toHaveLength(1); - expect(screen.getByRole('switch', { name: 'Activation for Send invoice on account' })).toBeChecked(); - }); - - it('keeps each row\'s refusal on its own row', async () => { - fixture.flip = [{ status: 403, body: errorEnvelope('PERMISSION_DENIED', POSTURE_REFUSAL) }]; - await renderSection(); - - await switchOff('Activation for Send invoice on account'); - await screen.findByText(POSTURE_REFUSAL); - - const invoiceRow = screen.getByTestId('packaged-action-account-send_invoice'); - const archiveRow = screen.getByTestId('packaged-action-account-archive_account'); - expect(within(invoiceRow).getByRole('alert')).toHaveTextContent('platform operator'); - expect(within(archiveRow).queryByRole('alert')).toBeNull(); - }); -}); - -/* -------------------------------------------------------------------------- */ -/* 4) No clone (ADR-0126 §8 item 2 — not chartered) */ -/* -------------------------------------------------------------------------- */ - -describe('no clone for actions', () => { - it('offers the switch and nothing else — no clone control anywhere', async () => { - await renderSection(); - - const section = screen.getByTestId('packaged-actions-section'); - expect(within(section).queryByRole('button', { name: /clone/i })).toBeNull(); - expect(within(section).queryByText(/clone/i)).toBeNull(); - expect(within(section).queryByText(/duplicate/i)).toBeNull(); - expect(within(section).queryByText(/copy/i)).toBeNull(); - // The switches ARE there — this asserts an absence beside a presence, so a - // section that failed to render could not pass it by rendering nothing. - expect(within(section).getAllByRole('switch')).toHaveLength(2); - }); -}); - -/* -------------------------------------------------------------------------- */ -/* 5) No ancestry or drift surface (ADR-0126 §9) */ -/* -------------------------------------------------------------------------- */ - -describe('no ancestry or drift surface', () => { - const WITHDRAWN = [ - /based on/i, - /customized/i, - /diff/i, - /compare/i, - /ancestry/i, - /lineage/i, - /out of date/i, - /base (has )?moved/i, - /upstream chang/i, - ]; - - it('shows a packaged action with no drift badge, no diff-vs-base and no base-moved notice', async () => { - await renderSection(); - for (const shape of WITHDRAWN) { - expect(screen.queryByText(shape)).toBeNull(); - } - expect(screen.queryByText(/based on v\d/i)).toBeNull(); - expect(screen.queryByText(/cloned from/i)).toBeNull(); - }); - - it('does not display ancestry even when the metadata and the flip response carry it', async () => { - // The platform tracks no such lineage, so these fields cannot arrive from - // a real server — feeding them anyway proves the ABSENCE is enforced by - // this section and not merely by the wire. - fixture.objects = [ - packagedObject('account', [ - { name: 'send_invoice', label: 'Send invoice', clonedFrom: 'base_send_invoice', baseVersion: 'v3' }, - ]), - ]; - fixture.flip = [ - { - status: 200, - body: { - success: true, - data: { - name: 'send_invoice', - objectName: 'account', - enabled: false, - clonedFrom: 'base_send_invoice', - baseVersion: 'v3', - }, - }, - }, - ]; - await renderSection(); - - await switchOff('Activation for Send invoice on account'); - await waitFor(() => - expect( - screen.getByRole('switch', { name: 'Activation for Send invoice on account' }), - ).not.toBeChecked(), - ); - - for (const shape of WITHDRAWN) { - expect(screen.queryByText(shape)).toBeNull(); - } - const section = screen.getByTestId('packaged-actions-section'); - expect(section.textContent).not.toContain('base_send_invoice'); - expect(section.textContent).not.toContain('v3'); - }); -}); - -/* -------------------------------------------------------------------------- */ -/* 6) The switch confirms off, says what happened, names the object */ -/* (objectstack#27521 row 20) */ -/* -------------------------------------------------------------------------- */ - -describe('the switch confirms off, says what happened, and names the object', () => { - beforeEach(() => { - vi.mocked(toast.success).mockClear(); - }); - - it('switching off asks first: Cancel sends nothing and leaves the switch on', async () => { - await renderSection(); - fireEvent.click(screen.getByRole('switch', { name: 'Activation for Send invoice on account' })); - - const dialog = await screen.findByTestId('packaged-action-off-dialog'); - expect(dialog).toHaveTextContent('Send invoice'); - expect(flipCalls()).toHaveLength(0); - - fireEvent.click(within(dialog).getByTestId('packaged-action-off-cancel')); - await waitFor(() => expect(screen.queryByTestId('packaged-action-off-dialog')).toBeNull()); - expect(flipCalls()).toHaveLength(0); - expect(screen.getByRole('switch', { name: 'Activation for Send invoice on account' })).toBeChecked(); - }); - - it('an accepted switch says so in a toast, off and then on; switching on asks nothing', async () => { - await renderSection(); - await switchOff('Activation for Send invoice on account'); - await waitFor(() => expect(toast.success).toHaveBeenCalledTimes(1)); - expect(vi.mocked(toast.success).mock.calls[0][0]).toContain('Send invoice'); - - fireEvent.click(screen.getByRole('switch', { name: 'Activation for Send invoice on account' })); - expect(screen.queryByTestId('packaged-action-off-dialog')).toBeNull(); - await waitFor(() => expect(toast.success).toHaveBeenCalledTimes(2)); - expect(flipCalls().map((c) => (c.body as { enabled: boolean }).enabled)).toEqual([false, true]); - }); - - it('CONTROL: a refused switch shows the refusal and no toast', async () => { - fixture.flip = [{ status: 403, body: errorEnvelope('PERMISSION_DENIED', POSTURE_REFUSAL) }]; - await renderSection(); - await switchOff('Activation for Send invoice on account'); - await screen.findByText(POSTURE_REFUSAL); - expect(toast.success).not.toHaveBeenCalled(); - }); - - it('draws the object by its label, with the machine name beside it', async () => { - fixture.objects = [ - { ...packagedObject('account', [{ name: 'send_invoice', label: 'Send invoice' }]), label: 'Account' }, - ]; - render(); - const row = await screen.findByTestId('packaged-action-account-send_invoice'); - expect(within(row).getByTestId('packaged-action-object-label')).toHaveTextContent('Account'); - expect(within(row).getByText('account')).toBeInTheDocument(); - }); -}); - -/* -------------------------------------------------------------------------- */ -/* 7) The object list is read in the session's language, and its served */ -/* object label is drawn as given (objectstack#30486) */ -/* -------------------------------------------------------------------------- */ - -/** - * The server translates each served object `label` for the request's - * `Accept-Language`, a `.custom` rename included, so the object read carries - * the SESSION's language and the column draws that label as given (the - * served-object-label rule, `servedObjectLabel`), never through the bundle's - * translation of the base package's name. An object served without a label - * shows its machine name alone, as before. - * - * Direction, written before the run: with the read's header dropped and the - * column put back to the bundle-first lookup, the header cell and the rename - * cell RED (no header; `客户`); the control GREEN on both sides. - */ -describe('the object column draws the served label, read in the session language (objectstack#30486)', () => { - function renderIn(lang: 'en' | 'zh-CN') { - const i18n = createI18n({ defaultLanguage: lang, detectBrowserLanguage: false }); - expect(i18n.language).toBe(lang); - // The base package's translation, which a rename must win over. - i18n.addResourceBundle(lang, 'translation', { - crm: { objects: { account: { label: lang === 'zh-CN' ? '客户' : 'Account' } } }, - }, true, true); - render( - - - , - ); - return screen.findByTestId('packaged-action-account-send_invoice'); - } - - const objectReadHeaders = () => - vi - .mocked(fetch) - .mock.calls.filter(([input]) => String(input).includes('/meta/object')) - .map(([, init]) => new Headers((init as RequestInit | undefined)?.headers)); - - it('asks for the object list in the session language', async () => { - await renderIn('zh-CN'); - const headers = objectReadHeaders(); - expect(headers.length).toBeGreaterThan(0); - for (const h of headers) expect(h.get('Accept-Language')).toBe('zh-CN'); - }); - - it('zh-CN: a served rename is drawn as given, not the bundle translation', async () => { - fixture.objects = [ - { ...packagedObject('account', [{ name: 'send_invoice', label: 'Send invoice' }]), label: '往来单位' }, - ]; - const row = await renderIn('zh-CN'); - expect(within(row).getByTestId('packaged-action-object-label')).toHaveTextContent('往来单位'); - expect(within(row).queryByText('客户')).toBeNull(); - }); - - it('en: a served rename is drawn as given', async () => { - fixture.objects = [ - { ...packagedObject('account', [{ name: 'send_invoice', label: 'Send invoice' }]), label: 'Counterparty' }, - ]; - const row = await renderIn('en'); - expect(within(row).getByTestId('packaged-action-object-label')).toHaveTextContent('Counterparty'); - }); - - it('CONTROL: an object served without a label shows only its machine name', async () => { - fixture.objects = [ - { name: 'account', actions: [{ name: 'send_invoice', label: 'Send invoice' }], _packageId: 'com.objectstack.crm', _provenance: 'package' }, - ]; - const row = await renderIn('zh-CN'); - expect(within(row).queryByTestId('packaged-action-object-label')).toBeNull(); - expect(within(row).getByText('account')).toBeInTheDocument(); - }); -}); diff --git a/ui/packages/app-shell/src/views/setup/PackagedActionsSection.tsx b/ui/packages/app-shell/src/views/setup/PackagedActionsSection.tsx deleted file mode 100644 index 02bcce1c2b3..00000000000 --- a/ui/packages/app-shell/src/views/setup/PackagedActionsSection.tsx +++ /dev/null @@ -1,502 +0,0 @@ -// Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license. - -/** - * PackagedActionsSection — Setup › Packaged actions (ADR-0126 §7.4 page, §8 - * item 2 charter, amendment ruling 3), the half of Setup › Packaged automation - * that stayed in Setup when objectstack ADR-0146 D11 retired that page: D4 keeps - * the action switch here, and the flows half moved into Studio. - * - * The maintainer's pull, verbatim and untranslated: - * - * > 「动作 可能是需要开关的,因为有的 action 我不想启用。」 - * - * ## What this section is, and what it deliberately is not - * - * Per packaged action it does exactly ONE thing: **on/off for this scope**. - * That is all the `sys_metadata_activation` ledger knows about an action, and - * the section claims nothing more. - * - * ⛔ **No clone.** A packaged flow is copied (ADR-0126 §7.1; Studio's New - * similar since objectstack ADR-0146 D4); - * ruling 3 charters the SWITCH for actions and nothing else, and §8 item 2 - * keeps the clone half pre-chartered until real pull appears. A clone - * button here would advertise machinery that does not exist — which is - * also why the server's own §5 refusal for actions recommends the operator - * and an ordinary sibling action, where the flow refusal recommends a - * clone. - * ⛔ **No drift or ancestry surface** (§9): no "customized" badge, no - * diff-vs-base, no base-moved notice, no link from anything to a base. - * The platform does not track that lineage, so a surface showing it would - * be showing something it had to invent. `PackagedActionsSection.test.tsx` - * pins the absence, including against a response that smuggles such a - * field in, so a future "helpful" addition fails loudly. - * - * ## Where the two facts on a row come from - * - * `packagedActions.ts` holds the reading rules and the citation for each; the - * short version is that the artifacts come from the two declaration sources the - * runtime itself reads (`GET /meta/object` embedded `actions[]`, plus standalone - * `GET /meta/action` items) and the state comes from the `sys_metadata_activation` - * ledger, whose rows this page may list by the object's own declaration - * (`apiMethods: ['get', 'list']` — "Reads stay open so operability surfaces can - * answer 'what is disabled here?'"). Absence of a row means active. - * - * ## Server refusals reach the operator VERBATIM - * - * Three refusals are expected here and all three are the server's words, - * rendered as sent — ⛔ no client-side softening, shortening or re-wording, and - * ⛔ no retry loop (every one of the three is a verdict, not a hiccup): - * - * - **403 `PERMISSION_DENIED`** — the ADR-0126 §5 posture gate. In a - * `group` / `isolated` deployment the install-wide activation row requires - * the platform operator; the message names the posture AND the sanctioned - * path. Rewording it would drop the half that says what to do instead. - * - **409 `RESOURCE_CONFLICT`** — two objects declare this action name, and - * the ledger addresses an action by NAME (§4), so one row would switch - * every one of them. The message NAMES the objects, and that list is the - * entire value of the refusal — only the server can build it. - * - **503 `SERVICE_UNAVAILABLE`** — no activation ledger is attached to this - * deployment's engine, so nothing can be made durable. An outage is not a - * verdict about the action, and the message is the server's to phrase. - * - * `actionErrorDetail` reads the ADR-0112 envelope's message; the local fallback - * string is used ONLY when the response carried no message at all, never in - * place of one. - */ - -import * as React from 'react'; -import { toast } from 'sonner'; -import { - AlertDialog, - AlertDialogAction, - AlertDialogCancel, - AlertDialogContent, - AlertDialogDescription, - AlertDialogFooter, - AlertDialogHeader, - AlertDialogTitle, - Badge, - Empty, - EmptyDescription, - EmptyTitle, - Skeleton, - Switch, - Table, - TableBody, - TableCell, - TableHead, - TableHeader, - TableRow, -} from '@object-ui/components'; -import { useObjectLabel, useObjectTranslation } from '@object-ui/i18n'; -import { actionErrorDetail } from '@object-ui/core'; - -// The LEAF module, for the reason its own header gives: this section joins the -// page's graph, and the page is imported eagerly by `services/builtinComponents`. -import { apiBase } from '../../utils/apiBase.js'; -import { servedObjectLabel } from '../../hooks/servedObjectLabel.js'; -import { envelopeData, envelopeRefused } from './packagedFlows.js'; -import { - collectPackagedActions, - ledgerPageTruncated, - readActionActivation, - readDataRecords, - readMetadataItems, - type PackagedActionRow, -} from './packagedActions.js'; - -/* -------------------------------------------------------------------------- */ -/* Fetch helpers */ -/* -------------------------------------------------------------------------- */ - -const JSON_HEADERS = { Accept: 'application/json' } as const; - -/** - * How many ledger rows one page asks for. - * - * The ledger holds a row only for an artifact whose state was CHANGED from the - * packaged default, so this is orders of magnitude above any real installation - * — and the section does not rely on that being true: a response that reports - * `hasMore` is treated as a load failure rather than rendered, because a - * dropped row reads as "active" and would show a switched-off action as armed. - */ -const LEDGER_PAGE_SIZE = 1000; - -async function readJson(res: Response): Promise { - return res.json().catch(() => null); -} - -async function getJson(path: string, signal: AbortSignal, language?: string): Promise { - return fetch(`${apiBase()}${path}`, { - credentials: 'include', - headers: language ? { ...JSON_HEADERS, 'Accept-Language': language } : JSON_HEADERS, - cache: 'no-store', - signal, - }); -} - -/** - * The `object` metadata list — every object, for its embedded `actions[]` and - * its name. Asked in the SESSION's language (objectstack#30486): the server - * translates each served `label` for the request's `Accept-Language`, a - * `.custom` rename included, so the object column can draw it as given. A - * bare fetch carried the browser's language instead, and a zh-CN session in an - * English browser was served English names. - */ -async function fetchObjectMetadata(signal: AbortSignal, language: string | undefined): Promise { - const res = await getJson('/meta/object', signal, language); - if (!res.ok) throw new Error(`object metadata HTTP ${res.status}`); - return readMetadataItems(await readJson(res)); -} - -/** - * The standalone `action` metadata items. - * - * Tolerated as EMPTY when the read fails, and that is a transcription rather - * than a softening: the runtime's own `collectActionDeclarations` wraps this - * exact source in `try { … } catch { standalone = []; }` with the reason spelled - * out — *"no standalone-item source on this metadata service"*. A deployment - * whose metadata service cannot list standalone actions still has embedded ones - * to switch off, and failing the whole section there would take the off-switch - * away from every action to report the absence of an optional source. ⛔ The - * other two reads are NOT tolerated this way: an unreadable object list or an - * unreadable ledger means this section cannot say what it exists to say. - */ -async function fetchStandaloneActionMetadata(signal: AbortSignal): Promise { - try { - const res = await getJson('/meta/action', signal); - if (!res.ok) return []; - return readMetadataItems(await readJson(res)); - } catch (e) { - if ((e as { name?: string } | null)?.name === 'AbortError') throw e; - return []; - } -} - -/** The `sys_metadata_activation` rows — the activation EXCEPTIONS. */ -async function fetchActivationLedger(signal: AbortSignal): Promise> { - const res = await getJson(`/data/sys_metadata_activation?top=${LEDGER_PAGE_SIZE}`, signal); - if (!res.ok) throw new Error(`activation ledger HTTP ${res.status}`); - const json = await readJson(res); - if (ledgerPageTruncated(json)) { - // Refusing to render beats rendering the wrong direction: see - // `ledgerPageTruncated`. Untranslated on purpose — the same posture the - // flows half's `HTTP ` load errors take, which are the server's - // diagnostics and not operator copy. - throw new Error( - `activation ledger returned more than ${LEDGER_PAGE_SIZE} rows; refusing to show a partial ledger ` + - 'because a missing row reads as "active"', - ); - } - return readActionActivation(readDataRecords(json)); -} - -/* -------------------------------------------------------------------------- */ -/* Section */ -/* -------------------------------------------------------------------------- */ - -export interface PackagedActionsSectionProps { - /** - * Bumped by the page's Refresh control. One button refreshes both halves of - * the page — the alternative, a second Refresh beside this table, would let - * the two halves show states read at different moments with nothing saying so. - */ - nonce?: number; - /** - * Whether the section names itself (its heading and subtitle). The Packaged - * actions page says both in its page header, so it mounts the section - * without them. - */ - headed?: boolean; -} - -/** Row identity for busy/refusal bookkeeping: the pair the flip addresses. */ -function rowKey(row: Pick): string { - return `${row.objectName}:${row.name}`; -} - -export function PackagedActionsSection({ nonce = 0, headed = true }: PackagedActionsSectionProps) { - const { t, language } = useObjectTranslation(); - const { objectLabel } = useObjectLabel(); - - const [rows, setRows] = React.useState(null); - const [loadError, setLoadError] = React.useState(null); - /** Key of the action whose flip is in flight. */ - const [busyKey, setBusyKey] = React.useState(null); - /** Per-action server refusal, keyed by `:`. Verbatim. */ - const [refusals, setRefusals] = React.useState>({}); - /** - * The action whose switch-off waits on its confirm. Off stops the action - * everywhere it is offered, for every user, so it is asked first; on - * restores it and runs at once. - */ - const [pendingOff, setPendingOff] = React.useState(null); - - React.useEffect(() => { - const controller = new AbortController(); - let cancelled = false; - setLoadError(null); - (async () => { - try { - const [objects, standalone, activation] = await Promise.all([ - fetchObjectMetadata(controller.signal, language), - fetchStandaloneActionMetadata(controller.signal), - fetchActivationLedger(controller.signal), - ]); - if (cancelled) return; - setRows(collectPackagedActions(objects, standalone, activation)); - } catch (e) { - if (cancelled || controller.signal.aborted) return; - setRows([]); - setLoadError( - e instanceof Error && e.message - ? e.message - : t('packagedAutomation.actionsLoadFailed', { - defaultValue: 'Could not load packaged actions.', - }), - ); - } - })(); - return () => { - cancelled = true; - controller.abort(); - }; - }, [nonce, t, language]); - - const clearRefusal = React.useCallback((key: string) => { - setRefusals((prev) => { - if (!(key in prev)) return prev; - const next = { ...prev }; - delete next[key]; - return next; - }); - }, []); - - async function onToggle(row: PackagedActionRow, enabled: boolean) { - const key = rowKey(row); - setBusyKey(key); - clearRefusal(key); - try { - const res = await fetch( - `${apiBase()}/actions/_activation/${encodeURIComponent(row.objectName)}/${encodeURIComponent(row.name)}`, - { - method: 'POST', - credentials: 'include', - headers: { ...JSON_HEADERS, 'Content-Type': 'application/json' }, - // ⛔ EXACTLY the one key the activation body declares. The door - // refuses unknown keys by name, and it is right to: the flow toggle's - // #3899 lesson is that an unchecked `{"enable": false}` — one letter - // off — ENABLED the artifact and answered 200. - body: JSON.stringify({ enabled }), - }, - ); - const json = await readJson(res); - if (!res.ok || envelopeRefused(json)) { - // VERBATIM. All three expected refusals carry the whole of what the - // administrator needs in this string, and two of them carry something - // no client could reconstruct: the objects a name collides across, and - // the reason this deployment cannot make the switch durable. - setRefusals((prev) => ({ - ...prev, - [key]: actionErrorDetail( - json, - // A SEPARATE key from the catch arm's below: this one has a status - // to name and that one does not, and one key cannot carry a hole - // only half its call sites can fill. - t('packagedAutomation.toggleFailedHttp', { - defaultValue: 'Could not change activation (HTTP {{status}}).', - status: res.status, - }), - ), - })); - return; - } - const reported = envelopeData(json).enabled; - const next = typeof reported === 'boolean' ? reported : enabled; - setRows( - (prev) => prev?.map((r) => (rowKey(r) === key ? { ...r, enabled: next } : r)) ?? prev, - ); - toast.success( - next - ? t('packagedAutomation.switchedOn', { defaultValue: '"{{label}}" is switched on.', label: row.label }) - : t('packagedAutomation.switchedOff', { - defaultValue: '"{{label}}" is switched off for this deployment.', - label: row.label, - }), - ); - } catch (e) { - setRefusals((prev) => ({ - ...prev, - [key]: - e instanceof Error && e.message - ? e.message - : t('packagedAutomation.toggleFailed', { defaultValue: 'Could not change activation.' }), - })); - } finally { - setBusyKey(null); - } - } - - return ( -
- {headed && ( -
-

- {t('packagedAutomation.actionsHeading', { defaultValue: 'Packaged actions' })} -

-

- {t('packagedAutomation.actionsSubtitle', { - defaultValue: - 'Actions shipped by installed packages. Turn one off for this deployment and it stops running everywhere it is offered. Authoring your own action alongside it stays open in Studio.', - })} -

-
- )} - - {loadError && ( -
- {loadError} -
- )} - - {rows === null && ( -
- - -
- )} - - {rows !== null && rows.length === 0 && !loadError && ( - - - {t('packagedAutomation.actionsEmptyTitle', { defaultValue: 'No packaged actions' })} - - - {t('packagedAutomation.actionsEmptyBody', { - defaultValue: - 'No installed package declares an action on this deployment. Actions you author yourself live in Studio.', - })} - - - )} - - {rows !== null && rows.length > 0 && ( - - - - {t('packagedAutomation.colAction', { defaultValue: 'Action' })} - {/* Fixed column widths from `sm` up only, as the flows table - above: on a phone the columns share the width. */} - - {t('packagedAutomation.colObject', { defaultValue: 'Object' })} - - - {t('packagedAutomation.colActivation', { defaultValue: 'Activation' })} - - - - - {rows.map((row) => { - const key = rowKey(row); - const refusal = refusals[key]; - return ( - - -
{row.label}
- {row.name} - {refusal && ( - // VERBATIM server refusal, next to the control that - // caused it. `role="alert"` so it is announced. -

- {refusal} -

- )} -
- - {/* The object's label in the reader's language, over the - machine name, which is also the `:object` segment the - flip addresses — `global` for an object-less action, - the platform's own spelling, drawn alone. The label is - the one the server served for this session's language, - drawn as given (the served-object-label rule, - objectstack#30486), never re-translated by the client - bundle, whose base-package name would win a rename - back. An object served without a label shows its - machine name alone. */} - {row.objectLabel && ( -
- {servedObjectLabel({ name: row.objectName, label: row.objectLabel }, language, objectLabel)} -
- )} - {row.objectName} -
- -
- - next ? void onToggle(row, true) : setPendingOff(row) - } - // The object is part of the accessible name because it - // is part of the identity: two objects may declare the - // same action name, and a label without the object - // would name two switches identically. - aria-label={t('packagedAutomation.actionToggleLabel', { - defaultValue: 'Activation for {{label}} on {{object}}', - label: row.label, - object: row.objectName, - })} - /> - - {row.enabled - ? t('packagedAutomation.on', { defaultValue: 'On' }) - : t('packagedAutomation.off', { defaultValue: 'Off' })} - -
-
-
- ); - })} -
-
- )} - - !open && setPendingOff(null)}> - - - - {t('packagedAutomation.actionOffTitle', { - defaultValue: 'Switch "{{label}}" off?', - label: pendingOff?.label ?? '', - })} - - - {t('packagedAutomation.actionOffBody', { - defaultValue: - 'It stops running everywhere it is offered on this deployment, for every user, until it is switched on again.', - })} - - - - - {t('packagedAutomation.cancel', { defaultValue: 'Cancel' })} - - { - const target = pendingOff; - setPendingOff(null); - if (target) void onToggle(target, false); - }} - > - {t('packagedAutomation.actionOffConfirm', { defaultValue: 'Switch off' })} - - - - -
- ); -} - -export default PackagedActionsSection; diff --git a/ui/packages/app-shell/src/views/setup/packagedActionLedger.ts b/ui/packages/app-shell/src/views/setup/packagedActionLedger.ts new file mode 100644 index 00000000000..1109db6e4bf --- /dev/null +++ b/ui/packages/app-shell/src/views/setup/packagedActionLedger.ts @@ -0,0 +1,242 @@ +// Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license. + +/** + * The packaged-action ledger switch Studio offers on a read-only app's vendor + * actions (objectstack#34724, the ADR-0146 D4 amendment of 2026-11-17): on the + * object's Actions view in the Data pillar, and on a standalone `action` + * item's page in the "All metadata" area. Setup's Packaged Actions page, which + * held the switch before, is retired. + * + * It is the flow switch's twin (`packagedFlowLedger.ts`), over the action's + * own two doors, which are the ones that page used: + * + * - the READ is the `sys_metadata_activation` ledger's generic list (rows + * with `metadata_type: 'action'`), read by `packagedActions.ts`'s rules: + * absence of a row means active, a truncated page is a failed read; + * - the WRITE is `POST /actions/_activation/:object/:action` + * (objectstack#12348), body exactly `{ enabled }`. + * + * The gate is the one the flow door has (`refuseUngrantedActivationWrite` + * serves both doors), so it is pre-judged by the same function, + * {@link flowLedgerWalledReadOnly}. Every refusal reaches the operator + * VERBATIM through `actionErrorDetail`; a fallback is used only when the + * response carried no message, in the caller's own words. + * + * ## No switch on a platform action + * + * The maintainer's ruling on the card: the platform's own actions (those a + * kernel package ships, on `sys_user`, `sys_api_key`, `sys_sso_provider` …) + * carry no switch anywhere. {@link useActionLedger} offers one only for a + * package the package list serves as an app package + * ({@link isAppPackageListed}); a kernel package, an unlisted id and a list + * that could not be read all answer no switch. The server door is unchanged. + */ + +import * as React from 'react'; +import { actionErrorDetail } from '@object-ui/core'; +import { apiBase } from '../../utils/apiBase.js'; +import { fetchPackages, type PkgEntry } from '../studio-design/packages-io.js'; +import { envelopeData, envelopeRefused } from './packagedFlows.js'; +import { ledgerPageTruncated, readActionActivation, readDataRecords } from './packagedActions.js'; +import { useFlowLedgerWalledReadOnly, type FlowDoorFallbacks } from './packagedFlowLedger.js'; + +/** + * How many ledger rows one read asks for. The ledger holds a row only for an + * item whose state was changed from the packaged default, so this is orders of + * magnitude above any real installation, and a response that reports + * `hasMore` is still refused (`ledgerPageTruncated`): a dropped row reads as + * "active". + */ +export const ACTION_LEDGER_PAGE_SIZE = 1000; + +/** The toggle's answer: the flag the server reports, or its refusal verbatim. */ +export type ActionToggleOutcome = { ok: true; enabled: boolean } | { ok: false; message: string }; + +async function readJson(res: Response): Promise { + return res.json().catch(() => null); +} + +/** + * The activation EXCEPTIONS, action name → armed. Rejects on a failed or + * truncated read with a diagnostic (untranslated, as the flow half's + * `HTTP ` load errors are), never with a partial map. + */ +export async function fetchActionLedger(signal?: AbortSignal): Promise> { + const res = await fetch(`${apiBase()}/data/sys_metadata_activation?top=${ACTION_LEDGER_PAGE_SIZE}`, { + credentials: 'include', + headers: { Accept: 'application/json' }, + cache: 'no-store', + signal, + }); + const json = await readJson(res); + if (!res.ok || envelopeRefused(json)) { + throw new Error(actionErrorDetail(json, `activation ledger HTTP ${res.status}`)); + } + if (ledgerPageTruncated(json)) { + throw new Error( + `activation ledger returned more than ${ACTION_LEDGER_PAGE_SIZE} rows; refusing to show a partial ledger ` + + 'because a missing row reads as "active"', + ); + } + return readActionActivation(readDataRecords(json)); +} + +/** + * `POST /actions/_activation/:object/:action`. Never throws: a refusal comes + * back as the server's sentence. The posture gate (403), the name collision + * across objects (409, which names the objects) and the missing ledger (503) + * each carry the whole of what the operator needs in that string. + */ +export async function requestActionToggle( + objectName: string, + name: string, + enabled: boolean, + fallbacks: FlowDoorFallbacks, +): Promise { + try { + const res = await fetch( + `${apiBase()}/actions/_activation/${encodeURIComponent(objectName)}/${encodeURIComponent(name)}`, + { + method: 'POST', + credentials: 'include', + headers: { Accept: 'application/json', 'Content-Type': 'application/json' }, + // ⛔ EXACTLY the one key the body declares: the door refuses unknown + // keys by name (the flow toggle's #3899 lesson). + body: JSON.stringify({ enabled }), + }, + ); + const json = await readJson(res); + if (!res.ok || envelopeRefused(json)) { + return { ok: false, message: actionErrorDetail(json, fallbacks.http(res.status)) }; + } + const reported = envelopeData(json).enabled; + return { ok: true, enabled: typeof reported === 'boolean' ? reported : enabled }; + } catch (e) { + return { ok: false, message: e instanceof Error && e.message ? e.message : fallbacks.network }; + } +} + +/** + * Is `packageId` an app package — listed by the package list as a package the + * switcher offers, and not a kernel one? Only then do its actions get a + * switch. `null` (no package) answers no. + */ +export function isAppPackageListed(entries: readonly PkgEntry[], packageId: string | null): boolean { + if (!packageId) return false; + return entries.some((entry) => entry.id === packageId && entry.kernel !== true); +} + +/** What a surface needs to draw the action switch for one package. */ +export interface ActionLedgerHandle { + /** + * `true` once the package is known to be an app package and the ledger has + * answered; `false` while either is unknown and for good on a platform + * package. No switch is drawn until it is `true`. + */ + offered: boolean; + /** The ledger flag for one action: `true` when no row says otherwise. */ + enabledOf: (name: string) => boolean; + /** The ledger read's failure, as a diagnostic; the switches stay undrawn. */ + loadError: string | null; + /** The door refuses this caller on this deployment (the posture facts' verdict). */ + walled: boolean; + /** The `:` whose flip is in flight. */ + busyKey: string | null; + /** The server's refusal of the last flip, by `:`, verbatim. */ + refusalOf: (objectName: string, name: string) => string | undefined; + /** Flip one action; resolves with the new flag, or `null` when refused. */ + toggle: (objectName: string, name: string, fallbacks: FlowDoorFallbacks) => Promise; +} + +const keyOf = (objectName: string, name: string) => `${objectName}:${name}`; + +/** + * The action switch's state for one read-only package's surface. `packageId` + * `null` (a writable package, or no package) offers nothing and reads nothing. + */ +export function useActionLedger(packageId: string | null): ActionLedgerHandle { + const walled = useFlowLedgerWalledReadOnly(); + const [appPackage, setAppPackage] = React.useState<{ for: string; app: boolean } | null>(null); + const [ledger, setLedger] = React.useState | null>(null); + const [loadError, setLoadError] = React.useState(null); + const [busyKey, setBusyKey] = React.useState(null); + const [refusals, setRefusals] = React.useState>({}); + + React.useEffect(() => { + if (!packageId) return; + let cancelled = false; + fetchPackages() + .then((entries) => { + if (!cancelled) setAppPackage({ for: packageId, app: isAppPackageListed(entries, packageId) }); + }) + .catch(() => { + // An unread list is no answer: no switch, the platform-safe direction. + if (!cancelled) setAppPackage({ for: packageId, app: false }); + }); + return () => { + cancelled = true; + }; + }, [packageId]); + + const app = !!packageId && appPackage?.for === packageId && appPackage.app; + + React.useEffect(() => { + if (!app) return; + const controller = new AbortController(); + fetchActionLedger(controller.signal) + .then((map) => { + if (controller.signal.aborted) return; + setLoadError(null); + setLedger(map); + }) + .catch((e: unknown) => { + if (controller.signal.aborted) return; + setLedger(null); + setLoadError(e instanceof Error && e.message ? e.message : String(e)); + }); + return () => controller.abort(); + }, [app]); + + const enabledOf = React.useCallback((name: string) => ledger?.get(name) ?? true, [ledger]); + const refusalOf = React.useCallback( + (objectName: string, name: string) => refusals[keyOf(objectName, name)], + [refusals], + ); + + const toggle = React.useCallback( + async (objectName: string, name: string, fallbacks: FlowDoorFallbacks): Promise => { + if (!ledger || walled) return null; + const key = keyOf(objectName, name); + setBusyKey(key); + setRefusals((prev) => { + if (!(key in prev)) return prev; + const next = { ...prev }; + delete next[key]; + return next; + }); + const outcome = await requestActionToggle(objectName, name, !(ledger.get(name) ?? true), fallbacks); + setBusyKey(null); + if (!outcome.ok) { + setRefusals((prev) => ({ ...prev, [key]: outcome.message })); + return null; + } + setLedger((prev) => { + const next = new Map(prev ?? []); + next.set(name, outcome.enabled); + return next; + }); + return outcome.enabled; + }, + [ledger, walled], + ); + + return { + offered: app && ledger !== null, + enabledOf, + loadError: app ? loadError : null, + walled, + busyKey, + refusalOf, + toggle, + }; +} diff --git a/ui/packages/app-shell/src/views/setup/packagedActions.test.ts b/ui/packages/app-shell/src/views/setup/packagedActions.test.ts index d8de4de1a0c..2c8a376f06c 100644 --- a/ui/packages/app-shell/src/views/setup/packagedActions.test.ts +++ b/ui/packages/app-shell/src/views/setup/packagedActions.test.ts @@ -1,39 +1,24 @@ // Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license. /** - * Which actions the packaged-ACTIONS section lists, and how it reads the two - * responses behind a row (ADR-0126 §8 item 2). - * - * The rules worth measuring here are the ones a DOM render cannot show cheaply - * and that a wrong answer would make the page lie about, in this order of - * consequence: - * - * 1. an activation row read from the wrong ledger slice, or from a driver - * that spells booleans 0/1, shows a switched-OFF action as armed; - * 2. the provenance question is asked of the wrong ITEM for an embedded - * action, which either hides an action from its only off-switch or offers - * an install-wide switch for something a tenant authored; - * 3. the `:` dedup runs the wrong way and the row's label and - * provenance come from a declaration the server would not have resolved. + * How the packaged-action ledger switch reads the responses behind it + * (ADR-0126 §8 item 2; Studio's switch since objectstack#34724). The rule + * worth measuring here is the one a DOM render cannot show cheaply and that a + * wrong answer would make the switch lie about: an activation row read from + * the wrong ledger slice, or from a driver that spells booleans 0/1, shows a + * switched-OFF action as armed. And the object segment the flip addresses. */ import { describe, expect, it } from 'vitest'; import { GLOBAL_ACTION_OBJECT, - collectPackagedActions, ledgerPageTruncated, - packagedActionSource, readActionActivation, readDataRecords, standaloneActionObjectName, } from './packagedActions'; -/** A packaged object carrying embedded action declarations. */ -function packagedObject(name: string, actions: Array>) { - return { name, label: name, actions, _packageId: 'com.objectstack.crm', _provenance: 'package' }; -} - /** One `sys_metadata_activation` row as the data API answers it. */ function ledgerRow(over: Record) { return { @@ -126,7 +111,7 @@ describe('readActionActivation', () => { }); /* -------------------------------------------------------------------------- */ -/* Owning object + provenance source */ +/* Owning object */ /* -------------------------------------------------------------------------- */ describe('standaloneActionObjectName', () => { @@ -144,123 +129,3 @@ describe('standaloneActionObjectName', () => { expect(GLOBAL_ACTION_OBJECT).toBe('global'); }); }); - -describe('packagedActionSource', () => { - const obj = { name: 'account', _packageId: 'com.objectstack.crm', _provenance: 'package' }; - - it('falls through to the owning object for an embedded action', () => { - // The registry stamps provenance on the item it registers — the object — - // so an embedded action carries none and cannot answer for itself. - expect(packagedActionSource({ name: 'send_invoice' }, obj)).toBe(obj); - }); - - it('lets a standalone item answer for itself, in both directions', () => { - const packaged = { name: 'a', _packageId: 'com.objectstack.crm' }; - expect(packagedActionSource(packaged, obj)).toBe(packaged); - // The case the fall-through would get wrong: a tenant-authored action - // sitting on a PACKAGED object. It carries its own provenance, so it - // answers, and the answer is "not packaged". - const tenant = { name: 'a', _provenance: 'org' }; - expect(packagedActionSource(tenant, obj)).toBe(tenant); - }); -}); - -/* -------------------------------------------------------------------------- */ -/* The join */ -/* -------------------------------------------------------------------------- */ - -describe('collectPackagedActions', () => { - const objects = [ - packagedObject('account', [ - { name: 'send_invoice', label: 'Send invoice' }, - { name: 'archive', label: 'Archive' }, - ]), - // A tenant-authored object overlay BOUND to a package: it carries a real - // package id, so only the provenance clause keeps its actions off the page. - { name: 'my_object', label: 'Mine', _packageId: 'app.crm', _provenance: 'org', actions: [{ name: 'mine', label: 'Mine' }] }, - ]; - - it('lists the packaged embedded actions and leaves a tenant object\'s out', () => { - const rows = collectPackagedActions(objects, [], new Map()); - expect(rows.map((r) => r.name)).toEqual(['archive', 'send_invoice']); - expect(rows.every((r) => r.objectName === 'account')).toBe(true); - }); - - it('defaults to active and applies the ledger exceptions by name', () => { - const rows = collectPackagedActions(objects, [], new Map([['send_invoice', false]])); - // Absence of a row means the packaged default — active. - expect(rows.find((r) => r.name === 'archive')?.enabled).toBe(true); - expect(rows.find((r) => r.name === 'send_invoice')?.enabled).toBe(false); - }); - - it('includes a packaged STANDALONE action under its declared object', () => { - const rows = collectPackagedActions( - objects, - [{ name: 'reindex', label: 'Reindex', objectName: 'account', _packageId: 'com.objectstack.crm', _provenance: 'package' }], - new Map(), - ); - expect(rows.find((r) => r.name === 'reindex')).toMatchObject({ - objectName: 'account', - label: 'Reindex', - enabled: true, - }); - }); - - it('lists an object-less standalone action under `global`', () => { - const rows = collectPackagedActions( - [], - [{ name: 'nightly', label: 'Nightly', _packageId: 'com.objectstack.crm', _provenance: 'package' }], - new Map(), - ); - expect(rows).toEqual([ - { name: 'nightly', objectName: GLOBAL_ACTION_OBJECT, label: 'Nightly', enabled: true }, - ]); - }); - - it('lets the OBJECT-EMBEDDED declaration win a key clash', () => { - // `collectActionDeclarations`' rule, mirroring the execution layer's - // artifact-wins precedence. Backwards, the row would carry the label and - // provenance of a declaration the server would never resolve or flip. - const rows = collectPackagedActions( - objects, - [{ name: 'send_invoice', label: 'STANDALONE COPY', objectName: 'account', _packageId: 'com.objectstack.crm' }], - new Map(), - ); - const hits = rows.filter((r) => r.name === 'send_invoice'); - expect(hits).toHaveLength(1); - expect(hits[0].label).toBe('Send invoice'); - }); - - it('keeps BOTH rows when two objects declare the same action name', () => { - // The ledger addresses an action by name alone (§4), so one row reaches - // both — and the write door refuses the flip with a 409 that NAMES the - // objects. Hiding a row here would replace that explanation with a guess. - const rows = collectPackagedActions( - [ - packagedObject('account', [{ name: 'export', label: 'Export' }]), - packagedObject('contact', [{ name: 'export', label: 'Export' }]), - ], - [], - new Map([['export', false]]), - ); - expect(rows.map((r) => r.objectName)).toEqual(['account', 'contact']); - // One ledger row, so both rows read the same state. That IS what the - // ledger says, and the page reports it rather than inventing per-object - // state the platform does not keep. - expect(rows.every((r) => r.enabled === false)).toBe(true); - }); - - it('falls back to the machine name when a declaration has no label', () => { - const rows = collectPackagedActions([packagedObject('account', [{ name: 'raw' }])], [], new Map()); - expect(rows[0].label).toBe('raw'); - }); - - it('skips a declaration with no usable name', () => { - const rows = collectPackagedActions( - [packagedObject('account', [{ label: 'nameless' }, { name: '' }])], - [], - new Map(), - ); - expect(rows).toEqual([]); - }); -}); diff --git a/ui/packages/app-shell/src/views/setup/packagedActions.ts b/ui/packages/app-shell/src/views/setup/packagedActions.ts index ed18d538a9b..138f78abf9a 100644 --- a/ui/packages/app-shell/src/views/setup/packagedActions.ts +++ b/ui/packages/app-shell/src/views/setup/packagedActions.ts @@ -1,44 +1,37 @@ // Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license. /** - * The reading rules behind the packaged-ACTIONS half of Setup › Packaged - * automation (ADR-0126 §7.4 page, §8 item 2 charter) — which actions the - * section lists, and how it reads the two responses it depends on. - * - * Separate from `PackagedActionsSection.tsx` for the same reason - * `packagedFlows.ts` is separate from the page: these are not components, the - * scoping rule is the part most worth testing directly, and reaching it - * through the DOM costs a full render. It runs in the `unit` project from here. - * - * ## Where each of the two facts comes from - * - * A row needs two things the platform keeps in two different places, and the - * flows half's shape is mirrored exactly — one read for the ARTIFACTS, one for - * the ACTIVATION STATE, joined here: - * - * 1. **Which actions exist, on which object, and did a package ship them.** - * Actions are declared in two places and the runtime reads BOTH - * (`collectActionDeclarations`, `@objectstack/runtime`'s - * `action-execution.ts`): embedded in an object's `actions[]`, and as - * standalone `action` metadata items. The two HTTP reads are `GET - * /meta/object` and `GET /meta/action`. Listing only the first would leave - * an administrator with no off-switch for a packaged standalone action — - * the same defect `packagedFlows.ts` names for a filtered-out flow. + * The reading rules behind the packaged-action ledger switch (ADR-0126 §8 + * item 2 charter) — how the two responses it depends on are read. Written for + * Setup › Packaged Actions, which objectstack#34724 (the ADR-0146 D4 amendment + * of 2026-11-17) retired; Studio's action switch reads through them + * (`packagedActionLedger.ts`), on a read-only app's vendor actions. + * + * Not components, so the rules are tested directly, in the `unit` project. + * + * ## Where each fact comes from + * + * 1. **Which object an action is addressed under.** Actions are declared in + * two places and the runtime reads BOTH (`collectActionDeclarations`, + * `@objectstack/runtime`'s `action-execution.ts`): embedded in an object's + * `actions[]`, and as standalone `action` metadata items. The flip's + * `:object` segment is the owning object, or {@link GLOBAL_ACTION_OBJECT} + * ({@link standaloneActionObjectName}). * 2. **Whether it is switched off here.** The `sys_metadata_activation` * ledger, rows carrying `metadata_type: 'action'` (ADR-0126 §4). That * object declares `apiMethods: ['get', 'list']` with the reason stated in * its own source — *"Reads stay open so operability surfaces can answer * 'what is disabled here?'"* — so the generic data API list IS the - * sanctioned read for this page. ⛔ There is no `_status`-style read door - * for actions to mirror the flows half with, and this page does not invent - * one: the write door (objectstack#12348) shipped the flip only. + * sanctioned read. ⛔ There is no `_status`-style read door for actions + * to mirror the flows half with, and none is invented here: the write + * door (objectstack#12348) shipped the flip only. * * ## Absence of a row means ACTIVE * * Nothing writes a row to say "active by default", so an empty ledger is the * ordinary stock-boot state and every action reads armed. That is the ledger's - * own contract (ADR-0126 §4) and it is why {@link collectPackagedActions} takes - * a map of the exceptions rather than a state per action. + * own contract (ADR-0126 §4), and it is why {@link readActionActivation} + * answers a map of the exceptions rather than a state per action. * * ## What this module deliberately does NOT compute (ADR-0126 §9) * @@ -48,57 +41,21 @@ * lineage, so a field claiming it would be invented here. */ -// The provenance predicate is imported, ⛔ not transcribed a second time. Its -// clauses (`_packageId` present, not the `sys_metadata` sentinel, `_provenance` -// not `'org'`) are about a REGISTRY ITEM's origin — they read the two keys the -// registry stamps on every metadata item, and say nothing about flows. Its -// header carries the whole argument for each clause and the cloud#970 -// measurement behind the middle one; one definition, cited from both halves of -// this page, cannot drift the way two agreeing copies can. -import { isPackagedFlowItem, readMetadataItems } from './packagedFlows.js'; - /** - * The object segment an OBJECT-LESS action takes, on the wire and on this page. + * The object segment an OBJECT-LESS action takes, on the wire and on the switch. * * `GLOBAL_ACTION_OBJECT_KEY` in `@objectstack/objectql`'s `action-governance.ts` * (a server package, so the value is transcribed rather than imported). The * activation door's path is `POST /actions/_activation/:object/:action` with the * object segment MANDATORY — *"use `global` for an object-less action"*, the * same spelling the invocation door takes — so this is the literal string that - * goes in the URL, and showing it in the object column is showing what the flip - * will actually address. + * goes in the URL, and the flip addresses exactly this. */ export const GLOBAL_ACTION_OBJECT = 'global'; -/** The `sys_metadata_activation` discriminator this section reads. */ +/** The `sys_metadata_activation` discriminator these readers take. */ export const ACTION_METADATA_TYPE = 'action'; -/** A packaged action as the section renders it. */ -export interface PackagedActionRow { - /** - * The declarative machine name (ADR-0110 D1) — the ledger's row key AND the - * `:action` segment of the activation door. - */ - name: string; - /** - * The owning object's machine name, or {@link GLOBAL_ACTION_OBJECT}. The - * `:object` segment of the activation door. - */ - objectName: string; - /** Display name; falls back to the machine name when the item has none. */ - label: string; - /** - * The owning object's label as `GET /meta/object` serves it, when the - * object is in that list and declares one. The section reads that list in - * the session's language, so this is already the reader's name for the - * object, a `.custom` rename included; the page draws it as given - * (objectstack#30486) and keeps the machine name beside it. - */ - objectLabel?: string; - /** Activation as the ledger reports it — `true` when no row says otherwise. */ - enabled: boolean; -} - /** * The record list out of `GET /data/:object`, wrapped or bare. * @@ -122,14 +79,14 @@ export function readDataRecords(payload: unknown): Array * * This matters more here than pagination usually does, because of which way the * lie points: a missing row reads as ACTIVE, so a dropped page would show an - * action an administrator switched OFF as armed — a page that quietly - * contradicts the deployment on the one fact it exists to report. The section + * action an administrator switched OFF as armed — a switch that quietly + * contradicts the deployment on the one fact it exists to report. The switch * therefore treats a truncated read as a load failure and shows nothing, rather * than rendering a list it already knows is wrong. * * Only an explicit `hasMore === true` counts. The field is optional in * `FindDataResponse`; a backend that omits it is not asserting truncation, and - * inventing one from a row count would need a page size this page does not know. + * inventing one from a row count would need a page size the reader does not know. */ export function ledgerPageTruncated(payload: unknown): boolean { const p = payload as { data?: { hasMore?: unknown }; hasMore?: unknown } | null | undefined; @@ -143,7 +100,7 @@ export function ledgerPageTruncated(payload: unknown): boolean { * A clause-for-clause transcription of `ObjectStoreActionActivationStore.list()` * (`@objectstack/objectql`'s `action-activation.ts`), which cannot be imported * here (a server package). Each clause is the store's, and each one changes - * what this page shows: + * what the switch shows: * * - **`metadata_type === 'action'`.** The ledger is generic (ADR-0126 §4) and * flow rows share the table today. Reading a flow's row as an action's @@ -180,7 +137,7 @@ export function readActionActivation( * `objectName`, bundle-collector `object`, else the `global` wildcard. It has to * agree, because the string it returns becomes the `:object` segment of the * flip — a different answer here would address a declaration the server cannot - * resolve, and the door would 404 on an action the page had just listed. + * resolve, and the door would 404 on an action the switch was drawn for. */ export function standaloneActionObjectName(action: unknown): string { const a = action as { objectName?: unknown; object?: unknown } | null | undefined; @@ -188,109 +145,3 @@ export function standaloneActionObjectName(action: unknown): string { if (typeof a?.object === 'string' && a.object.length > 0) return a.object; return GLOBAL_ACTION_OBJECT; } - -/** - * Which item answers the "did a package ship this?" question for one action. - * - * An action EMBEDDED in an object's `actions[]` is a plain sub-object: the - * registry stamps `_packageId` / `_provenance` on the ITEM it registers, which - * is the object, so an embedded action carries neither and its owning object is - * the only thing that can answer. A STANDALONE `action` item is registered in - * its own right and answers for itself. - * - * This is the read-side twin of how the activation door derives the package it - * writes into the row — `declaration.action._packageId ?? declaration.obj._packageId` - * — so the page classifies an action the same way the server does. The test is - * "does the action carry provenance marks of its own", not "is `_packageId` - * truthy": an action that carries `_provenance: 'org'` and no package id has - * answered, and falling through to its packaged owning object would list a - * tenant-authored action as packaged. - */ -export function packagedActionSource(action: unknown, obj: unknown): unknown { - const a = action as { _packageId?: unknown; _provenance?: unknown } | null | undefined; - if (typeof a?._packageId === 'string' || typeof a?._provenance === 'string') return action; - return obj; -} - -/** - * Join the two declaration sources with the activation ledger, scoped to the - * PACKAGED actions. - * - * The collection order and the dedup rule are transcribed from - * `collectActionDeclarations` (`@objectstack/runtime`), including the one that - * is easy to miss: on a `:` key clash the OBJECT-EMBEDDED - * declaration wins, mirroring the execution layer's artifact-wins rule. Getting - * that backwards would not just reorder the list — it would show a row whose - * label and provenance came from a declaration that is not the one the server - * would resolve and flip. - * - * ⚠️ Two objects may declare the SAME action name, and both rows are listed. - * That is not a bug being papered over: the ledger addresses an action by its - * machine name alone (§4), so one row would reach both, and the write door - * refuses the flip with a `409 RESOURCE_CONFLICT` that NAMES the objects. - * Hiding one row here, or disabling its switch, would replace the server's - * explanation with a client-side guess about a conflict only the server can - * describe. - */ -export function collectPackagedActions( - objectItems: readonly unknown[], - standaloneItems: readonly unknown[], - activation: ReadonlyMap, -): PackagedActionRow[] { - const rows: PackagedActionRow[] = []; - const seen = new Set(); - - const push = (action: unknown, objectName: string, obj: unknown) => { - const a = action as { name?: unknown; label?: unknown } | null; - const name = a?.name; - if (typeof name !== 'string' || !name) return; - const key = `${objectName}:${name}`; - if (seen.has(key)) return; - seen.add(key); - if (!isPackagedFlowItem(packagedActionSource(action, obj))) return; - const label = a?.label; - const objectLabel = (obj as { label?: unknown } | null | undefined)?.label; - rows.push({ - name, - objectName, - label: typeof label === 'string' && label ? label : name, - ...(typeof objectLabel === 'string' && objectLabel ? { objectLabel } : {}), - enabled: activation.get(name) ?? true, - }); - }; - - const objByName = new Map(); - for (const raw of objectItems) { - const obj = raw as { name?: unknown } | null; - if (typeof obj?.name === 'string' && obj.name) objByName.set(obj.name, raw); - } - - // 1. Object-embedded declarations first — they win the key clash below. - for (const raw of objectItems) { - const obj = raw as { name?: unknown; actions?: unknown } | null; - const objectName = obj?.name; - if (typeof objectName !== 'string' || !objectName) continue; - for (const action of Array.isArray(obj?.actions) ? obj.actions : []) { - push(action, objectName, raw); - } - } - - // 2. Standalone `action` items, skipped where an embedded declaration of the - // same `:` key already claimed the slot. - for (const action of standaloneItems) { - const objectName = standaloneActionObjectName(action); - push(action, objectName, objByName.get(objectName)); - } - - return rows.sort( - (a, b) => - a.label.localeCompare(b.label) || - a.objectName.localeCompare(b.objectName) || - a.name.localeCompare(b.name), - ); -} - -// Re-exported so the section reads its two metadata responses through the SAME -// reader the flows half uses for `GET /meta/flow` — one answer to "bare array or -// `{ items }`?", for every `/meta` list this page reads. -export { readMetadataItems }; diff --git a/ui/packages/app-shell/src/views/studio-design/FlowLedgerSwitch.tsx b/ui/packages/app-shell/src/views/studio-design/FlowLedgerSwitch.tsx index 1d35dcf5066..8285b3ea6b5 100644 --- a/ui/packages/app-shell/src/views/studio-design/FlowLedgerSwitch.tsx +++ b/ui/packages/app-shell/src/views/studio-design/FlowLedgerSwitch.tsx @@ -36,7 +36,18 @@ import { t } from '../metadata-admin/i18n.js'; import { STUDIO_FOLD_LABEL } from './studio-tokens.js'; import type { ActivationReading } from '../setup/packagedFlows.js'; -export function FlowLedgerSwitch({ checked, reading, notRunningReason, busy, walledReason, locale, onToggle }: { +export function FlowLedgerSwitch({ + checked, + reading, + notRunningReason, + busy, + walledReason, + locale, + onToggle, + hint: hintText, + testId = 'auto-ledger-switch', + label, +}: { /** The ledger flag. */ checked: boolean; /** What the flag means on this deployment (`activationReading`). */ @@ -49,11 +60,24 @@ export function FlowLedgerSwitch({ checked, reading, notRunningReason, busy, wal walledReason?: string; locale: string; onToggle: () => void; + /** + * objectstack#34724 — the switch's one-line sentence, when the item is not a + * flow: a packaged action's switch says what it switches. Defaults to the + * flow's. + */ + hint?: string; + /** objectstack#34724 — the action switch's own test id; the flow's by default. */ + testId?: string; + /** + * objectstack#34724 — an accessible name of its own, where one view draws a + * switch per item. Absent, the visible word names it, as on the flow header. + */ + label?: string; }): React.ReactElement { const hintId = React.useId(); const reasonId = React.useId(); const notRunningId = React.useId(); - const hint = t('engine.studio.auto.ledger.hint', locale); + const hint = hintText ?? t('engine.studio.auto.ledger.hint', locale); const notRunning = reading === 'not-running'; const why = notRunning && notRunningReason ? notRunningReason : undefined; const describedBy = [hintId, why ? notRunningId : '', walledReason ? reasonId : ''].filter(Boolean).join(' '); @@ -62,8 +86,9 @@ export function FlowLedgerSwitch({ checked, reading, notRunningReason, busy, wal type="button" role="switch" aria-checked={checked} - data-testid="auto-ledger-switch" + data-testid={testId} data-reading={reading} + aria-label={label} onClick={() => { if (!busy) onToggle(); }} diff --git a/ui/packages/app-shell/src/views/studio-design/ObjectActionsPanel.ledgerSwitch-34724.test.tsx b/ui/packages/app-shell/src/views/studio-design/ObjectActionsPanel.ledgerSwitch-34724.test.tsx new file mode 100644 index 00000000000..5a44f4e8ce1 --- /dev/null +++ b/ui/packages/app-shell/src/views/studio-design/ObjectActionsPanel.ledgerSwitch-34724.test.tsx @@ -0,0 +1,239 @@ +// Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license. + +/** + * objectstack#34724 (ADR-0146 D4 as amended 2026-11-17) — a read-only app's + * vendor action carries the activation ledger's switch on the object's Actions + * view; Setup's Packaged Actions page, which held it, retired. + * + * What is pinned, in the order an operator meets it: + * 1. the switch binds the ledger flag (no row → on; an `active: false` row → + * off, and the list row says so); + * 2. a flip sends exactly `{ enabled }` to + * `POST /api/v1/actions/_activation/:object/:action` and the switch takes + * the flag the server reports; + * 3. a refusal is the server's sentence, verbatim, in a `role="alert"`; + * 4. a caller the door walls off sees the switch disabled with the + * console's reason, not a live control that answers 403; + * 5. a platform (kernel) package's actions get no switch, nor does a + * writable package's (whose actions are the draft's), and a failed + * ledger read draws no switch but says why. + */ + +import '@testing-library/jest-dom/vitest'; +import * as React from 'react'; +import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'; +import { cleanup, fireEvent, render, screen, waitFor } from '@testing-library/react'; +import { MemoryRouter, Route, Routes } from 'react-router-dom'; +import { I18nProvider } from '@object-ui/i18n'; + +let posture: string | undefined; +let operator: boolean | undefined; + +vi.mock('../../hooks/useTenancyPosture', async (importOriginal) => ({ + ...(await importOriginal>()), + useTenancyPosture: () => posture, +})); +vi.mock('@object-ui/auth', async (importOriginal) => { + const mod = await importOriginal(); + return { + ...mod, + useAuth: () => ({ + ...mod.useAuth(), + user: { id: 'u_caller', name: 'Caller', email: 'caller@example.com', isPlatformAdmin: operator }, + }), + }; +}); + +// The package list as `parsePackages` answers it: the switcher's entries. A +// manifest-scoped kernel package is not among them; a flat-scoped one is, +// flagged `kernel`. +const packageEntries = vi.hoisted(() => ({ + current: [] as Array<{ id: string; name: string; writable: boolean; namespace: string; kernel?: true }>, +})); +vi.mock('./packages-io', async (importOriginal) => { + const mod = await importOriginal(); + return { ...mod, fetchPackages: vi.fn(async () => packageEntries.current) }; +}); + +vi.mock('sonner', () => ({ toast: { success: vi.fn(), error: vi.fn() } })); + +import { toast } from 'sonner'; +import { ObjectActionsPanel } from './ObjectActionsPanel'; +import { fetchPackages } from './packages-io'; + +const APP = 'com.example.showcase'; +const FLAT_KERNEL = 'com.objectstack.platform-objects'; + +const draft = { + name: 'showcase_task', + label: 'Task', + actions: [ + { name: 'clone_task', label: 'Clone task', type: 'script', target: 'clone_task' }, + { name: 'close_task', label: 'Close task', type: 'script', target: 'close_task' }, + ], +}; + +type Answer = { status: number; body: unknown }; +let ledgerAnswer: Answer; +let toggleAnswer: Answer; +let fetchMock: ReturnType; + +const ok = (body: unknown): Answer => ({ status: 200, body }); +const ledgerRows = (rows: Array>) => + ok({ success: true, data: { object: 'sys_metadata_activation', records: rows } }); + +beforeEach(() => { + posture = 'single'; + operator = false; + packageEntries.current = [ + { id: APP, name: 'Showcase', writable: false, namespace: 'showcase' }, + { id: FLAT_KERNEL, name: 'Platform objects', writable: false, namespace: 'sys', kernel: true }, + ]; + ledgerAnswer = ledgerRows([]); + toggleAnswer = ok({ success: true, data: { enabled: false } }); + fetchMock = vi.fn(async (url: string) => { + const answer = String(url).includes('/actions/_activation/') ? toggleAnswer : ledgerAnswer; + return { ok: answer.status < 400, status: answer.status, json: async () => answer.body } as Response; + }); + vi.stubGlobal('fetch', fetchMock); + vi.mocked(toast.success).mockClear(); + vi.mocked(fetchPackages).mockClear(); +}); + +afterEach(() => { + cleanup(); + vi.unstubAllGlobals(); +}); + +function renderPanel({ pkg = APP, readOnly = true }: { pkg?: string; readOnly?: boolean } = {}) { + return render( + + + + {}} disabled={readOnly} />} + /> + + + , + ); +} + +const ledgerReads = () => fetchMock.mock.calls.filter(([url]) => String(url).includes('sys_metadata_activation')); + +describe('a read-only app\'s vendor action carries the ledger switch (objectstack#34724)', () => { + it('binds the ledger flag: no row reads on', async () => { + renderPanel(); + const sw = await screen.findByTestId('action-ledger-switch'); + expect(sw).toHaveAttribute('role', 'switch'); + expect(sw).toHaveAttribute('aria-checked', 'true'); + expect(sw).toHaveAttribute('data-reading', 'on'); + expect(sw).toHaveTextContent('Switched on for this deployment'); + expect(screen.queryByTestId('action-ledger-off-mark')).toBeNull(); + expect(String(ledgerReads()[0][0])).toBe('/api/v1/data/sys_metadata_activation?top=1000'); + }); + + it('an active:false action row reads off, on the switch and in the list', async () => { + ledgerAnswer = ledgerRows([ + { metadata_type: 'action', name: 'clone_task', package_id: APP, organization_id: null, active: false }, + // A flow's row of the same name is not the action's. + { metadata_type: 'flow', name: 'close_task', package_id: APP, organization_id: null, active: false }, + ]); + renderPanel(); + const sw = await screen.findByTestId('action-ledger-switch'); + expect(sw).toHaveAttribute('aria-checked', 'false'); + expect(sw).toHaveAttribute('data-reading', 'off'); + const marks = screen.getAllByTestId('action-ledger-off-mark'); + expect(marks).toHaveLength(1); + expect(marks[0].closest('button')).toHaveTextContent('Clone task'); + }); + + it('a flip sends exactly { enabled } to the action door and takes the flag the server reports', async () => { + renderPanel(); + fireEvent.click(await screen.findByTestId('action-ledger-switch')); + await waitFor(() => expect(screen.getByTestId('action-ledger-switch')).toHaveAttribute('aria-checked', 'false')); + const post = fetchMock.mock.calls.find(([url]) => String(url).includes('/actions/_activation/')); + expect(post?.[0]).toBe('/api/v1/actions/_activation/showcase_task/clone_task'); + expect(post?.[1]).toMatchObject({ method: 'POST', credentials: 'include' }); + expect(JSON.parse(String(post?.[1]?.body))).toEqual({ enabled: false }); + expect(toast.success).toHaveBeenCalledWith('"Clone task" is switched off for this deployment.'); + expect(screen.getByTestId('action-ledger-off-mark')).toBeInTheDocument(); + }); + + it('a refusal is the server\'s sentence, verbatim, in an alert, and the switch keeps its flag', async () => { + const sentence = + "Action 'clone_task' is declared by more than one object (showcase_task, showcase_project); the activation ledger addresses an action by name."; + toggleAnswer = { status: 409, body: { success: false, error: { code: 'RESOURCE_CONFLICT', message: sentence } } }; + renderPanel(); + fireEvent.click(await screen.findByTestId('action-ledger-switch')); + const alert = await screen.findByTestId('action-ledger-refusal'); + expect(alert).toHaveAttribute('role', 'alert'); + expect(alert).toHaveTextContent(sentence); + expect(screen.getByTestId('action-ledger-switch')).toHaveAttribute('aria-checked', 'true'); + expect(toast.success).not.toHaveBeenCalled(); + }); + + it('a caller the walled posture refuses sees it disabled, with the console\'s reason, and sends nothing', async () => { + posture = 'group'; + operator = false; + renderPanel(); + const sw = await screen.findByTestId('action-ledger-switch'); + expect(sw).toBeDisabled(); + expect(screen.getByTestId('auto-ledger-walled-reason')).toHaveTextContent( + 'On this deployment, only the platform operator can switch a packaged action on or off.', + ); + fireEvent.click(sw); + expect(fetchMock.mock.calls.some(([url]) => String(url).includes('/actions/_activation/'))).toBe(false); + }); + + it('the platform operator under the same posture gets a live switch', async () => { + posture = 'group'; + operator = true; + renderPanel(); + expect(await screen.findByTestId('action-ledger-switch')).not.toBeDisabled(); + }); +}); + +describe('no switch where the maintainer ruled none, and none where it means nothing (objectstack#34724)', () => { + it('a kernel package the switcher flags gets no switch, and its ledger is not read', async () => { + renderPanel({ pkg: FLAT_KERNEL }); + // The list renders (control), the switch never does. + expect(await screen.findAllByText('Clone task')).not.toHaveLength(0); + await waitFor(() => expect(vi.mocked(fetchPackages)).toHaveBeenCalled()); + expect(screen.queryByTestId('action-ledger-switch')).toBeNull(); + expect(ledgerReads()).toHaveLength(0); + }); + + it('a package the switcher does not list (a manifest-scoped kernel package) gets no switch', async () => { + renderPanel({ pkg: 'com.objectstack.auth' }); + expect(await screen.findAllByText('Clone task')).not.toHaveLength(0); + await waitFor(() => expect(vi.mocked(fetchPackages)).toHaveBeenCalled()); + expect(screen.queryByTestId('action-ledger-switch')).toBeNull(); + expect(ledgerReads()).toHaveLength(0); + }); + + it('an unreadable package list offers no switch (the platform-safe direction)', async () => { + vi.mocked(fetchPackages).mockRejectedValueOnce(new Error('HTTP 500')); + renderPanel(); + expect(await screen.findAllByText('Clone task')).not.toHaveLength(0); + await waitFor(() => expect(vi.mocked(fetchPackages)).toHaveBeenCalled()); + expect(screen.queryByTestId('action-ledger-switch')).toBeNull(); + }); + + it('a writable package\'s actions are the draft\'s: no switch, no ledger read', async () => { + renderPanel({ readOnly: false }); + expect(await screen.findAllByText('Clone task')).not.toHaveLength(0); + expect(screen.queryByTestId('action-ledger-switch')).toBeNull(); + expect(ledgerReads()).toHaveLength(0); + }); + + it('a failed ledger read draws no switch and says why', async () => { + ledgerAnswer = { status: 403, body: { success: false, error: { code: 'PERMISSION_DENIED', message: 'No read on sys_metadata_activation.' } } }; + renderPanel(); + const line = await screen.findByTestId('action-ledger-load-error'); + expect(line).toHaveAttribute('role', 'alert'); + expect(line).toHaveTextContent('No read on sys_metadata_activation.'); + expect(screen.queryByTestId('action-ledger-switch')).toBeNull(); + }); +}); diff --git a/ui/packages/app-shell/src/views/studio-design/ObjectActionsPanel.tsx b/ui/packages/app-shell/src/views/studio-design/ObjectActionsPanel.tsx index 291ae59f07b..5034f9f6a3d 100644 --- a/ui/packages/app-shell/src/views/studio-design/ObjectActionsPanel.tsx +++ b/ui/packages/app-shell/src/views/studio-design/ObjectActionsPanel.tsx @@ -58,10 +58,25 @@ * (`pairObjectActions.ts`). Each such action is listed after the vendor's * with the customization mark, opens editable and has Delete; "only * customizations" narrows the list to them. The object draft is not touched. + * + * ## A vendor action's switch for this deployment (objectstack#34724) + * + * On a read-only APP package, each vendor action opens with the activation + * ledger's switch in its header: on or off for this deployment, the flow + * switch's control and words (`FlowLedgerSwitch`, ADR-0146 D4 as amended + * 2026-11-17), over the action's own doors (`setup/packagedActionLedger.ts`). + * A refusal is the server's sentence, shown as sent under the switch; a caller + * the door walls off sees it disabled with the console's reason. A switched-off + * action says so in the list, so it is found from there. ⛔ A platform + * package's actions (a kernel package's, on `sys_user` and the like) carry no + * switch: the hook offers none for a package the list does not serve as an + * app package. Setup's Packaged Actions page, which held the switch, retired. */ import React from 'react'; -import { Ban, Zap, Plus, Trash2, ChevronDown, ChevronRight, Loader2 } from 'lucide-react'; +import { useParams } from 'react-router-dom'; +import { toast } from 'sonner'; +import { Ban, Zap, Plus, Trash2, ChevronDown, ChevronRight, Loader2, Power } from 'lucide-react'; import { useDisplayLocale } from '@object-ui/i18n'; import { Popover, PopoverTrigger, PopoverContent } from '@object-ui/components'; import { getIcon } from '../../utils/getIcon.js'; @@ -80,6 +95,9 @@ import { import { StudioEmptyState, StudioEmptyStateAction } from './StudioEmptyState.js'; import { usePairObjectActions, type PairActionsDoor } from './pairObjectActions.js'; import { RailCustomizationFilter, RailCustomizationMark, useRailCustomizationsOnly } from './StudioRailCustomizations.js'; +import { FlowLedgerSwitch } from './FlowLedgerSwitch.js'; +import { isStudioOrgScope } from './studioScope.js'; +import { useActionLedger } from '../setup/packagedActionLedger.js'; interface ActionItem { name?: string; @@ -198,6 +216,28 @@ export function ObjectActionsPanel({ // New is offered where an action can be saved: the object draft, or the pair. const canAdd = pair ? !pair.walled : !disabled; const [onlyAdded, toggleOnlyAdded] = useRailCustomizationsOnly(); + // objectstack#34724 — the ledger switch of a read-only package's vendor + // actions. The package is the route's: on a read-only package's object the + // vendor actions are that package's own. A writable package's actions are + // the draft's, switched by editing them, so nothing is read there. + const routePackage = useParams<{ packageId?: string }>().packageId ?? null; + const ledgerPackage = + disabled && routePackage && !isStudioOrgScope(routePackage) ? routePackage : null; + const ledger = useActionLedger(ledgerPackage); + const vendorNames = React.useMemo(() => new Set(actions.map((a) => String(a.name ?? ''))), [actions]); + // A listed action the switch is for: one of the vendor's, once the ledger answered. + const switchable = (name: string | null | undefined): boolean => + ledger.offered && !!name && vendorNames.has(String(name)); + const toggleLedger = async (name: string, label: string) => { + const now = await ledger.toggle(objectName, name, { + http: (status) => tFormat('engine.studio.auto.ledger.toggleFailedHttp', locale, { status }), + network: t('engine.studio.auto.ledger.toggleFailed', locale), + }); + if (now === null) return; + toast.success( + tFormat(now ? 'engine.studio.auto.ledger.switchedOn' : 'engine.studio.auto.ledger.switchedOff', locale, { label }), + ); + }; // objectui#11861 — new actions still waiting for their target: listed and // edited here, and NOT in the draft (see "A new action waits for its target" // above). Each is kept with the object it was started on (`on`, not the @@ -632,6 +672,18 @@ export function ObjectActionsPanel({ )} + {/* objectstack#34724 — a vendor action switched off for this + deployment says so in the list, where it is found. */} + {switchable(a.name) && !ledger.enabledOf(String(a.name)) && ( + + + )} {type && ( {type} @@ -671,6 +723,44 @@ export function ObjectActionsPanel({ {/* The list always selects an action, so this pane is never blank for want of a pick (objectui#12514 retired that sentence). */} {pairError} + {/* objectstack#34724 — a vendor action's switch for this + deployment, and what the server answered a flip, verbatim. */} + {sel && !editable(sel.name) && switchable(sel.name) && ( +
+
+ + void toggleLedger(String(sel.name), labelText(sel.label, String(sel.name ?? ''), locale)) + } + /> +
+ {ledger.refusalOf(objectName, String(sel.name)) && ( +

+ {ledger.refusalOf(objectName, String(sel.name))} +

+ )} +
+ )} + {sel && !editable(sel.name) && ledger.loadError && vendorNames.has(String(sel.name ?? '')) && ( +

+ {tFormat('engine.studio.actions.ledger.loadFailed', locale, { message: ledger.loadError })} +

+ )} {!sel ? null : Inspector ? ( <> {editable(sel.name) && ( diff --git a/ui/packages/app-shell/src/views/studio-design/noRetiredSetupLink-28578.test.ts b/ui/packages/app-shell/src/views/studio-design/noRetiredSetupLink-28578.test.ts index f8f89d62f96..942e648d0b5 100644 --- a/ui/packages/app-shell/src/views/studio-design/noRetiredSetupLink-28578.test.ts +++ b/ui/packages/app-shell/src/views/studio-design/noRetiredSetupLink-28578.test.ts @@ -4,11 +4,12 @@ * Studio links into no retired Setup page (objectstack ADR-0146; N-28). * * Setup › Packaged automation retired with D11: a packaged flow's switch and - * its copy (New similar) are Studio's, and the page's actions half is Setup's - * own `automation:packaged-actions` entry. A Studio file that still linked to - * the retired page would open a route nothing serves. This pin reads every - * non-test source under `views/studio-design/`, comments masked, and refuses - * any spelling of the retired ref or its URL. + * its copy (New similar) are Studio's. Setup › Packaged Actions, the page's + * actions half, retired with objectstack#34724: a packaged action's switch is + * Studio's too. A Studio file that still linked to either retired page would + * open a redirect back into Studio. This pin reads every non-test source under + * `views/studio-design/`, comments masked, and refuses any spelling of either + * retired ref or its URL. */ import { describe, it, expect } from 'vitest'; @@ -35,18 +36,23 @@ function sourceFiles(dir: string): string[] { return out; } -/** The retired ref (`automation:packaged`) or its URL (`…/component/automation/packaged`), not the actions entry. */ -const RETIRED = /automation[:/]packaged(?![\w-])/g; +/** + * The retired refs (`automation:packaged`, `automation:packaged-actions`) or + * their URLs (`…/component/automation/packaged[-actions]`). + */ +const RETIRED = /automation[:/]packaged(?:-actions)?(?![\w-])/g; describe('Studio links into no retired Setup page (ADR-0146)', () => { - it('the matcher sees the ref and the URL, and spares the actions entry', () => { + it('the matcher sees both refs and both URLs, and nothing longer', () => { expect("'/apps/setup/component/automation/packaged'".match(RETIRED)).toHaveLength(1); expect("const REF = 'automation:packaged';".match(RETIRED)).toHaveLength(1); - expect("'automation:packaged-actions'".match(RETIRED)).toBeNull(); + expect("'automation:packaged-actions'".match(RETIRED)).toHaveLength(1); + expect("'/apps/setup/component/automation/packaged-actions'".match(RETIRED)).toHaveLength(1); + expect("'automation:packaged-actions-v2'".match(RETIRED)).toBeNull(); expect(mask('// was automation:packaged\nconst a = 1;').match(RETIRED)).toBeNull(); }); - it('no Studio source opens the retired Setup › Packaged automation page (D11)', () => { + it('no Studio source opens a retired Setup › Packaged page (D11, objectstack#34724)', () => { const files = sourceFiles(here); // Control: the walk really reads the folder. expect(files.some((file) => file.endsWith('StudioDesignSurface.tsx'))).toBe(true); diff --git a/ui/packages/app-shell/src/views/studio-design/setupMetadataRedirect.test.ts b/ui/packages/app-shell/src/views/studio-design/setupMetadataRedirect.test.ts index 5a484308ead..8ba32ff0c66 100644 --- a/ui/packages/app-shell/src/views/studio-design/setupMetadataRedirect.test.ts +++ b/ui/packages/app-shell/src/views/studio-design/setupMetadataRedirect.test.ts @@ -10,6 +10,7 @@ import { describe, it, expect } from 'vitest'; import { SETUP_KEPT_METADATA_TYPE, + packagedActionsStudioPath, packagedAutomationStudioPath, setupMetadataRest, setupMetadataStudioPath, @@ -117,3 +118,15 @@ describe('packagedAutomationStudioPath (ADR-0146 D11)', () => { expect(areaLocationRedirect('~all', 'flow', target.search)).toBeNull(); }); }); + +describe('packagedActionsStudioPath (objectstack#34724)', () => { + it.each([ + // [search, hash, expected] + ['?package=crm', '', '/studio/crm/data?package=crm'], + ['?package=com.acme.app&x=1', '#top', '/studio/com.acme.app/data?package=com.acme.app&x=1#top'], + ['', '', '/studio'], + ['?package=all', '', '/studio?package=all'], + ])('%s%s → %s', (search, hash, expected) => { + expect(packagedActionsStudioPath(search, hash)).toBe(expected); + }); +}); diff --git a/ui/packages/app-shell/src/views/studio-design/setupMetadataRedirect.ts b/ui/packages/app-shell/src/views/studio-design/setupMetadataRedirect.ts index 1d78acc0cc1..8cc96de9485 100644 --- a/ui/packages/app-shell/src/views/studio-design/setupMetadataRedirect.ts +++ b/ui/packages/app-shell/src/views/studio-design/setupMetadataRedirect.ts @@ -73,3 +73,23 @@ export function packagedAutomationStudioPath(search: string, hash = ''): string if (pkg && pkg !== 'all') return `/studio/${encodeURIComponent(pkg)}/automations${tail}`; return `${studioMetadataAreaPath(STUDIO_ALL_PACKAGES_SEGMENT)}/flow${tail}`; } + +/** + * Where a bookmark of the retired Setup › Packaged Actions page lands + * (`/apps//component/automation/packaged-actions`, objectstack#34724, the + * ADR-0146 D4 amendment of 2026-11-17): Studio, where a packaged action's + * switch now is, on the action in its app. + * + * With `?package=` (not `all`), that app's Data pillar, whose objects' + * Actions views carry the switch, the query kept. With no package named (the + * page listed every package's actions), the Studio landing, which lists each + * installed app with its switched-off count. + */ +export function packagedActionsStudioPath(search: string, hash = ''): string { + const params = new URLSearchParams(search); + const query = params.toString(); + const tail = `${query ? `?${query}` : ''}${hash}`; + const pkg = params.get('package'); + if (pkg && pkg !== 'all') return `/studio/${encodeURIComponent(pkg)}/data${tail}`; + return `/studio${tail}`; +} diff --git a/ui/packages/core/src/utils/served-object-label.ts b/ui/packages/core/src/utils/served-object-label.ts index 648a1ffd7be..9a9b23c3a10 100644 --- a/ui/packages/core/src/utils/served-object-label.ts +++ b/ui/packages/core/src/utils/served-object-label.ts @@ -77,8 +77,7 @@ export function servedObjectPluralLabel( * drawn as given, since the server already translated it; the bundle's * `objectLabel` under the object's name only when the definition carries * none, with `fallback` as the bundle's own last resort. Every record-scoped - * surface reads it — the record page, its form, drawer and preview card, and - * the packaged-actions table's object column. + * surface reads it — the record page, its form, drawer and preview card. */ export function servedObjectLabel( objectDef: { name: string; label?: unknown }, diff --git a/ui/packages/i18n/src/namespaces/studio/en.ts b/ui/packages/i18n/src/namespaces/studio/en.ts index f43d7ad5d10..69e86ac472d 100644 --- a/ui/packages/i18n/src/namespaces/studio/en.ts +++ b/ui/packages/i18n/src/namespaces/studio/en.ts @@ -3653,6 +3653,12 @@ const STUDIO_EN: Record = { // Actions view 'engine.studio.actions.none': 'No actions on this object.', 'engine.studio.actions.newButton': 'New action', + // objectstack#34724 — a read-only app's vendor action: its ledger switch. + 'engine.studio.actions.ledger.hint': + 'This action comes from a read-only package. This switch only turns it on or off in this deployment and leaves the package unchanged.', + 'engine.studio.actions.ledger.walled': 'On this deployment, only the platform operator can switch a packaged action on or off.', + 'engine.studio.actions.ledger.offMark': 'Off', + 'engine.studio.actions.ledger.loadFailed': 'Could not read whether this action is switched on here: {message}', 'engine.studio.actions.editorMissing': 'No action editor is registered in this session, so this action’s properties cannot be edited here.', 'engine.studio.actions.newLabel': 'New action', diff --git a/ui/packages/i18n/src/namespaces/studio/zh.ts b/ui/packages/i18n/src/namespaces/studio/zh.ts index 4aa83f20d02..f5fb22e742a 100644 --- a/ui/packages/i18n/src/namespaces/studio/zh.ts +++ b/ui/packages/i18n/src/namespaces/studio/zh.ts @@ -3222,6 +3222,11 @@ const STUDIO_ZH: Record = { // Actions view 'engine.studio.actions.none': '该对象没有操作。', 'engine.studio.actions.newButton': '新建操作', + // objectstack#34724 — 只读应用的厂商动作:启停开关。 + 'engine.studio.actions.ledger.hint': '该动作来自只读软件包。此开关只在本部署中启用或停用它,不改动软件包本身。', + 'engine.studio.actions.ledger.walled': '在此部署中,只有平台运营方可以启用或停用打包动作。', + 'engine.studio.actions.ledger.offMark': '已停用', + 'engine.studio.actions.ledger.loadFailed': '无法读取该动作在本部署中是否启用:{message}', 'engine.studio.actions.editorMissing': '本次会话没有注册操作编辑器,因此无法在这里编辑该操作的属性。', 'engine.studio.actions.newLabel': '新操作', 'engine.studio.actions.delete': '删除', From 6271916f6fddf8e5421a817b171248ce692f5ba1 Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 17 Nov 2026 11:13:44 +0000 Subject: [PATCH 02/12] fix(studio): fold the contract and L1 review notes into the action switch change The ADR-0146 Status line records the 2026-11-17 amendment and D9 reads the switch in Studio; the changeset carries a BREAKING banner and the amended Clause-2 line; the spec sentence holds for a platform action too; the standalone action page judges the item's own package; the kernel scope list is pinned to the package doors'; the unused switch label prop is dropped. Co-Authored-By: Claude Claude-Session: https://claude.ai/code/session_01WGufziD6XhBNH9acXaG2Me --- .../34724-action-switch-moves-to-studio.md | 4 +++- content/docs/references/api/app-bundle.mdx | 10 +++++----- content/docs/references/api/protocol.mdx | 2 +- ...e-editor-per-item-paired-customize-package.md | 5 +++-- packages/objectql/src/action-activation.test.ts | 8 ++++++++ packages/objectql/src/engine-actions.ts | 7 ++++--- packages/objectql/src/engine.ts | 6 ++++++ packages/spec/src/api/protocol.zod.ts | 7 ++++--- ...rceEditPage.actionLedgerSwitch-34724.test.tsx | 16 +++++++++++++++- .../views/metadata-admin/ResourceEditPage.tsx | 5 ++++- .../src/views/studio-design/FlowLedgerSwitch.tsx | 7 ------- .../views/studio-design/ObjectActionsPanel.tsx | 3 ++- 12 files changed, 55 insertions(+), 25 deletions(-) diff --git a/.changeset/34724-action-switch-moves-to-studio.md b/.changeset/34724-action-switch-moves-to-studio.md index 5a93aedd2a4..ffccf41467a 100644 --- a/.changeset/34724-action-switch-moves-to-studio.md +++ b/.changeset/34724-action-switch-moves-to-studio.md @@ -11,9 +11,11 @@ feat(studio): an installed app's action is switched on or off on the action itself, in Studio; Setup › Packaged Actions retires (ADR-0146 D4, amended 2026-11-17) -Clause-②: yes (narrowing: the Setup `nav_packaged_actions` entry, its `automation:packaged-actions` page and the public `PackagedActionsPage` export of `@object-ui/app-shell` retire; widening: new studio-namespace locale keys) +Clause-②: yes (narrowing: Setup's `nav_packaged_actions` entry and its `automation:packaged-actions` console page retire, and `PackagedActionsPage` leaves the private `@object-ui/app-shell`; widening: new studio-namespace locale keys, an optional `options` argument and the exported `TurnedOffPackagedItemOptions` on `@objectstack/types`' `describeTurnedOffPackagedItem`, and `ActionActivationProjection.disabledPackageOf` plus an optional `platform` argument on `describeDisabled` in `@objectstack/objectql`) Metadata-protocol: none (no spec schema changes; `platform-objects` serves one fewer Setup navigation item, and one `.describe()` sentence changes) +**BREAKING** for an administrator who used Setup › Packaged Actions, and for a nav entry or link that names its `automation:packaged-actions` page: the Setup entry and page are gone. An installed app's action is now switched on or off on the action itself in Studio (the object's Actions view, or a standalone action's page), and an old link to the page opens Studio. A platform action (one a kernel package ships) has no switch in the console any more; it is switched through the activation door, `POST /api/v1/actions/_activation//`, and the `409 ACTION_DISABLED` message for one now says so. + Before this change, the deployment's on/off switch for an installed app's actions lived on a separate Setup page, "Packaged Actions", away from where the action is read. It now sits on the action: - On the object's Actions view in Studio, a read-only app package's vendor action carries a "Switched on / off for this deployment" switch, the flow switch's twin. A switched-off action is marked in the list. A refusal is the server's sentence, shown verbatim; a caller the deployment's posture walls off sees the switch disabled with the reason. diff --git a/content/docs/references/api/app-bundle.mdx b/content/docs/references/api/app-bundle.mdx index 10e5fec2e58..d2010cea54d 100644 --- a/content/docs/references/api/app-bundle.mdx +++ b/content/docs/references/api/app-bundle.mdx @@ -99,7 +99,7 @@ const result = AppMetadataBundleResponseSchema.parse(data); | **resettable** | `boolean` | optional | Whether the item can be reset to its packaged default — true iff it is artifact-backed, i.e. there is a baseline to reset TO. | | **version** | `string \| null` | optional | ADR-0008 version token of the STORED row a save to this item compares against, at this read's scope (the environment's partition and `?package=`) and lifecycle (`?state=draft` reads the draft row, the plain read the active row). The same keyed token a save receipt's `version` serves for that row: send it back as the `If-Match` request header on `PUT /meta/:type/:name` (with `?mode=draft` for the draft) and a concurrent edit is refused 409 `METADATA_CONFLICT` instead of overwritten. `null` when no stored row is there — an item served from code or a package artifact, or from a row in another scope (a package-less row a package read falls back to) — so the next save creates one: pin it with `If-None-Match: *`. A `null` beside `editable: false` is no such invitation: that item takes no save at this address, so no pin is prescribed for it. ABSENT on the cached published-value branch and on a `?preview=draft` read, which publish no version: absence means "not published here", never "no row". Opaque — echo it verbatim, never parse it. | | **registration** | `{ state: 'registered' } \| { state: 'refused'; reason: object } \| { state: 'unregistered' }` | optional | The automation engine's verdict on this flow (see `FlowRegistrationSchema`): `registered`, or `refused` with the engine's `reason` verbatim, or `unregistered`. Present only on a `flow` read answered by a process that runs an automation service; absent otherwise, and absence means no engine judged it, never `registered`. Unlike the protection keys it is published by the cached branch too, read live and never part of the ETag, so a cached read that carries it is never answered 304; it is absent on a draft read, whose pending body no engine holds. The verdict is the answering process's engine. Beside `item`, never inside it: the item's `status` stays what its author declared. | -| **disabledActions** | `string[]` | optional | The names in `item.actions` that this deployment's activation ledger switches off (an administrator turned them off on the action, in its package in Studio): a call to any of them is refused 409 `ACTION_DISABLED`. Present only on an `object` read answered by a process whose data engine has an activation ledger attached, and then `[]` when none of this object's actions is switched off. Absent otherwise, and absence means no ledger answered, never that nothing is switched off. Unlike the protection keys it is published by the cached branch too, read live and folded into the ETag, so a cached read revalidates to 304 only while the switched-off set is unchanged; it is absent on a draft read. The ledger is the answering process's engine's. Beside `item`, never inside it: `item.actions` is served as declared, a switched-off action included. | +| **disabledActions** | `string[]` | optional | The names in `item.actions` that this deployment's activation ledger switches off (an administrator turned them off through the activation door, for example on the action in Studio): a call to any of them is refused 409 `ACTION_DISABLED`. Present only on an `object` read answered by a process whose data engine has an activation ledger attached, and then `[]` when none of this object's actions is switched off. Absent otherwise, and absence means no ledger answered, never that nothing is switched off. Unlike the protection keys it is published by the cached branch too, read live and folded into the ETag, so a cached read revalidates to 304 only while the switched-off set is unchanged; it is absent on a draft read. The ledger is the answering process's engine's. Beside `item`, never inside it: `item.actions` is served as declared, a switched-off action included. | | **cascadeDeleteObjects** | `string[]` | optional | The objects, by name, that deleting a record of this object can also delete: every object whose relation into it cascades (a `master_detail` by default, a `lookup`, `tree` or `user` field that declares `deleteBehavior: 'cascade'`), and the objects that cascade into those in turn, each once, in the order the delete reaches them. This object itself is named only when a cascading relation leads back to it. A `restrict` or `set_null` relation removes nothing and is not named. Read from the rule the delete runs, and object-level: it never says which records or how many. Present only on an `object` read answered by a process whose data engine answers it, and then `[]` when nothing cascades. Absent otherwise, and absence means no engine answered, never that nothing cascades. Unlike the protection keys it is published by the cached branch too, read live and folded into the ETag; it is absent on a draft read. Beside `item`, never inside it: it is derived from other objects' definitions and is not authorable. | | **draftChanges** | `{ path: string[]; by: Enum<'copilot' \| 'mcp' \| 'studio' \| 'api'>; actor: string \| null; client?: object; … }[]` | optional | Per-key provenance of the pending draft: which authoring surface last changed each key path of `item`, under which actor, and when. The draft save records it: each draft save is compared with the body that save replaced (the previous draft, or the stored published row for the draft's first save; a draft of an item with no stored published row is recorded as `[]`, the whole body). A `migrate-stored` rewrite of a draft row records nothing, since it is not authoring. The entries are kept from the first recorded save until the draft is published or discarded, which remove the draft row and the entries with it; and no two entries share a path: a save replaces every entry at or under each path it changes, so the last write to change a key is the entry whose `path` is the longest prefix of that key's path, and entries under a key's path are changes inside it. The entries name which writes changed what; they are not a list of every difference from the published body (compare the two bodies for that). Served only on a `?state=draft` read that answers a stored draft row. ABSENT on the active read, the cached branch and a `?preview=draft` read, and for a draft row whose saves recorded none: absence means "not recorded", never "no changes". | @@ -123,7 +123,7 @@ const result = AppMetadataBundleResponseSchema.parse(data); | **resettable** | `boolean` | optional | Whether the item can be reset to its packaged default — true iff it is artifact-backed, i.e. there is a baseline to reset TO. | | **version** | `string \| null` | optional | ADR-0008 version token of the STORED row a save to this item compares against, at this read's scope (the environment's partition and `?package=`) and lifecycle (`?state=draft` reads the draft row, the plain read the active row). The same keyed token a save receipt's `version` serves for that row: send it back as the `If-Match` request header on `PUT /meta/:type/:name` (with `?mode=draft` for the draft) and a concurrent edit is refused 409 `METADATA_CONFLICT` instead of overwritten. `null` when no stored row is there — an item served from code or a package artifact, or from a row in another scope (a package-less row a package read falls back to) — so the next save creates one: pin it with `If-None-Match: *`. A `null` beside `editable: false` is no such invitation: that item takes no save at this address, so no pin is prescribed for it. ABSENT on the cached published-value branch and on a `?preview=draft` read, which publish no version: absence means "not published here", never "no row". Opaque — echo it verbatim, never parse it. | | **registration** | `{ state: 'registered' } \| { state: 'refused'; reason: object } \| { state: 'unregistered' }` | optional | The automation engine's verdict on this flow (see `FlowRegistrationSchema`): `registered`, or `refused` with the engine's `reason` verbatim, or `unregistered`. Present only on a `flow` read answered by a process that runs an automation service; absent otherwise, and absence means no engine judged it, never `registered`. Unlike the protection keys it is published by the cached branch too, read live and never part of the ETag, so a cached read that carries it is never answered 304; it is absent on a draft read, whose pending body no engine holds. The verdict is the answering process's engine. Beside `item`, never inside it: the item's `status` stays what its author declared. | -| **disabledActions** | `string[]` | optional | The names in `item.actions` that this deployment's activation ledger switches off (an administrator turned them off on the action, in its package in Studio): a call to any of them is refused 409 `ACTION_DISABLED`. Present only on an `object` read answered by a process whose data engine has an activation ledger attached, and then `[]` when none of this object's actions is switched off. Absent otherwise, and absence means no ledger answered, never that nothing is switched off. Unlike the protection keys it is published by the cached branch too, read live and folded into the ETag, so a cached read revalidates to 304 only while the switched-off set is unchanged; it is absent on a draft read. The ledger is the answering process's engine's. Beside `item`, never inside it: `item.actions` is served as declared, a switched-off action included. | +| **disabledActions** | `string[]` | optional | The names in `item.actions` that this deployment's activation ledger switches off (an administrator turned them off through the activation door, for example on the action in Studio): a call to any of them is refused 409 `ACTION_DISABLED`. Present only on an `object` read answered by a process whose data engine has an activation ledger attached, and then `[]` when none of this object's actions is switched off. Absent otherwise, and absence means no ledger answered, never that nothing is switched off. Unlike the protection keys it is published by the cached branch too, read live and folded into the ETag, so a cached read revalidates to 304 only while the switched-off set is unchanged; it is absent on a draft read. The ledger is the answering process's engine's. Beside `item`, never inside it: `item.actions` is served as declared, a switched-off action included. | | **cascadeDeleteObjects** | `string[]` | optional | The objects, by name, that deleting a record of this object can also delete: every object whose relation into it cascades (a `master_detail` by default, a `lookup`, `tree` or `user` field that declares `deleteBehavior: 'cascade'`), and the objects that cascade into those in turn, each once, in the order the delete reaches them. This object itself is named only when a cascading relation leads back to it. A `restrict` or `set_null` relation removes nothing and is not named. Read from the rule the delete runs, and object-level: it never says which records or how many. Present only on an `object` read answered by a process whose data engine answers it, and then `[]` when nothing cascades. Absent otherwise, and absence means no engine answered, never that nothing cascades. Unlike the protection keys it is published by the cached branch too, read live and folded into the ETag; it is absent on a draft read. Beside `item`, never inside it: it is derived from other objects' definitions and is not authorable. | | **draftChanges** | `{ path: string[]; by: Enum<'copilot' \| 'mcp' \| 'studio' \| 'api'>; actor: string \| null; client?: object; … }[]` | optional | Per-key provenance of the pending draft: which authoring surface last changed each key path of `item`, under which actor, and when. The draft save records it: each draft save is compared with the body that save replaced (the previous draft, or the stored published row for the draft's first save; a draft of an item with no stored published row is recorded as `[]`, the whole body). A `migrate-stored` rewrite of a draft row records nothing, since it is not authoring. The entries are kept from the first recorded save until the draft is published or discarded, which remove the draft row and the entries with it; and no two entries share a path: a save replaces every entry at or under each path it changes, so the last write to change a key is the entry whose `path` is the longest prefix of that key's path, and entries under a key's path are changes inside it. The entries name which writes changed what; they are not a list of every difference from the published body (compare the two bodies for that). Served only on a `?state=draft` read that answers a stored draft row. ABSENT on the active read, the cached branch and a `?preview=draft` read, and for a draft row whose saves recorded none: absence means "not recorded", never "no changes". | @@ -147,7 +147,7 @@ const result = AppMetadataBundleResponseSchema.parse(data); | **resettable** | `boolean` | optional | Whether the item can be reset to its packaged default — true iff it is artifact-backed, i.e. there is a baseline to reset TO. | | **version** | `string \| null` | optional | ADR-0008 version token of the STORED row a save to this item compares against, at this read's scope (the environment's partition and `?package=`) and lifecycle (`?state=draft` reads the draft row, the plain read the active row). The same keyed token a save receipt's `version` serves for that row: send it back as the `If-Match` request header on `PUT /meta/:type/:name` (with `?mode=draft` for the draft) and a concurrent edit is refused 409 `METADATA_CONFLICT` instead of overwritten. `null` when no stored row is there — an item served from code or a package artifact, or from a row in another scope (a package-less row a package read falls back to) — so the next save creates one: pin it with `If-None-Match: *`. A `null` beside `editable: false` is no such invitation: that item takes no save at this address, so no pin is prescribed for it. ABSENT on the cached published-value branch and on a `?preview=draft` read, which publish no version: absence means "not published here", never "no row". Opaque — echo it verbatim, never parse it. | | **registration** | `{ state: 'registered' } \| { state: 'refused'; reason: object } \| { state: 'unregistered' }` | optional | The automation engine's verdict on this flow (see `FlowRegistrationSchema`): `registered`, or `refused` with the engine's `reason` verbatim, or `unregistered`. Present only on a `flow` read answered by a process that runs an automation service; absent otherwise, and absence means no engine judged it, never `registered`. Unlike the protection keys it is published by the cached branch too, read live and never part of the ETag, so a cached read that carries it is never answered 304; it is absent on a draft read, whose pending body no engine holds. The verdict is the answering process's engine. Beside `item`, never inside it: the item's `status` stays what its author declared. | -| **disabledActions** | `string[]` | optional | The names in `item.actions` that this deployment's activation ledger switches off (an administrator turned them off on the action, in its package in Studio): a call to any of them is refused 409 `ACTION_DISABLED`. Present only on an `object` read answered by a process whose data engine has an activation ledger attached, and then `[]` when none of this object's actions is switched off. Absent otherwise, and absence means no ledger answered, never that nothing is switched off. Unlike the protection keys it is published by the cached branch too, read live and folded into the ETag, so a cached read revalidates to 304 only while the switched-off set is unchanged; it is absent on a draft read. The ledger is the answering process's engine's. Beside `item`, never inside it: `item.actions` is served as declared, a switched-off action included. | +| **disabledActions** | `string[]` | optional | The names in `item.actions` that this deployment's activation ledger switches off (an administrator turned them off through the activation door, for example on the action in Studio): a call to any of them is refused 409 `ACTION_DISABLED`. Present only on an `object` read answered by a process whose data engine has an activation ledger attached, and then `[]` when none of this object's actions is switched off. Absent otherwise, and absence means no ledger answered, never that nothing is switched off. Unlike the protection keys it is published by the cached branch too, read live and folded into the ETag, so a cached read revalidates to 304 only while the switched-off set is unchanged; it is absent on a draft read. The ledger is the answering process's engine's. Beside `item`, never inside it: `item.actions` is served as declared, a switched-off action included. | | **cascadeDeleteObjects** | `string[]` | optional | The objects, by name, that deleting a record of this object can also delete: every object whose relation into it cascades (a `master_detail` by default, a `lookup`, `tree` or `user` field that declares `deleteBehavior: 'cascade'`), and the objects that cascade into those in turn, each once, in the order the delete reaches them. This object itself is named only when a cascading relation leads back to it. A `restrict` or `set_null` relation removes nothing and is not named. Read from the rule the delete runs, and object-level: it never says which records or how many. Present only on an `object` read answered by a process whose data engine answers it, and then `[]` when nothing cascades. Absent otherwise, and absence means no engine answered, never that nothing cascades. Unlike the protection keys it is published by the cached branch too, read live and folded into the ETag; it is absent on a draft read. Beside `item`, never inside it: it is derived from other objects' definitions and is not authorable. | | **draftChanges** | `{ path: string[]; by: Enum<'copilot' \| 'mcp' \| 'studio' \| 'api'>; actor: string \| null; client?: object; … }[]` | optional | Per-key provenance of the pending draft: which authoring surface last changed each key path of `item`, under which actor, and when. The draft save records it: each draft save is compared with the body that save replaced (the previous draft, or the stored published row for the draft's first save; a draft of an item with no stored published row is recorded as `[]`, the whole body). A `migrate-stored` rewrite of a draft row records nothing, since it is not authoring. The entries are kept from the first recorded save until the draft is published or discarded, which remove the draft row and the entries with it; and no two entries share a path: a save replaces every entry at or under each path it changes, so the last write to change a key is the entry whose `path` is the longest prefix of that key's path, and entries under a key's path are changes inside it. The entries name which writes changed what; they are not a list of every difference from the published body (compare the two bodies for that). Served only on a `?state=draft` read that answers a stored draft row. ABSENT on the active read, the cached branch and a `?preview=draft` read, and for a draft row whose saves recorded none: absence means "not recorded", never "no changes". | @@ -171,7 +171,7 @@ const result = AppMetadataBundleResponseSchema.parse(data); | **resettable** | `boolean` | optional | Whether the item can be reset to its packaged default — true iff it is artifact-backed, i.e. there is a baseline to reset TO. | | **version** | `string \| null` | optional | ADR-0008 version token of the STORED row a save to this item compares against, at this read's scope (the environment's partition and `?package=`) and lifecycle (`?state=draft` reads the draft row, the plain read the active row). The same keyed token a save receipt's `version` serves for that row: send it back as the `If-Match` request header on `PUT /meta/:type/:name` (with `?mode=draft` for the draft) and a concurrent edit is refused 409 `METADATA_CONFLICT` instead of overwritten. `null` when no stored row is there — an item served from code or a package artifact, or from a row in another scope (a package-less row a package read falls back to) — so the next save creates one: pin it with `If-None-Match: *`. A `null` beside `editable: false` is no such invitation: that item takes no save at this address, so no pin is prescribed for it. ABSENT on the cached published-value branch and on a `?preview=draft` read, which publish no version: absence means "not published here", never "no row". Opaque — echo it verbatim, never parse it. | | **registration** | `{ state: 'registered' } \| { state: 'refused'; reason: object } \| { state: 'unregistered' }` | optional | The automation engine's verdict on this flow (see `FlowRegistrationSchema`): `registered`, or `refused` with the engine's `reason` verbatim, or `unregistered`. Present only on a `flow` read answered by a process that runs an automation service; absent otherwise, and absence means no engine judged it, never `registered`. Unlike the protection keys it is published by the cached branch too, read live and never part of the ETag, so a cached read that carries it is never answered 304; it is absent on a draft read, whose pending body no engine holds. The verdict is the answering process's engine. Beside `item`, never inside it: the item's `status` stays what its author declared. | -| **disabledActions** | `string[]` | optional | The names in `item.actions` that this deployment's activation ledger switches off (an administrator turned them off on the action, in its package in Studio): a call to any of them is refused 409 `ACTION_DISABLED`. Present only on an `object` read answered by a process whose data engine has an activation ledger attached, and then `[]` when none of this object's actions is switched off. Absent otherwise, and absence means no ledger answered, never that nothing is switched off. Unlike the protection keys it is published by the cached branch too, read live and folded into the ETag, so a cached read revalidates to 304 only while the switched-off set is unchanged; it is absent on a draft read. The ledger is the answering process's engine's. Beside `item`, never inside it: `item.actions` is served as declared, a switched-off action included. | +| **disabledActions** | `string[]` | optional | The names in `item.actions` that this deployment's activation ledger switches off (an administrator turned them off through the activation door, for example on the action in Studio): a call to any of them is refused 409 `ACTION_DISABLED`. Present only on an `object` read answered by a process whose data engine has an activation ledger attached, and then `[]` when none of this object's actions is switched off. Absent otherwise, and absence means no ledger answered, never that nothing is switched off. Unlike the protection keys it is published by the cached branch too, read live and folded into the ETag, so a cached read revalidates to 304 only while the switched-off set is unchanged; it is absent on a draft read. The ledger is the answering process's engine's. Beside `item`, never inside it: `item.actions` is served as declared, a switched-off action included. | | **cascadeDeleteObjects** | `string[]` | optional | The objects, by name, that deleting a record of this object can also delete: every object whose relation into it cascades (a `master_detail` by default, a `lookup`, `tree` or `user` field that declares `deleteBehavior: 'cascade'`), and the objects that cascade into those in turn, each once, in the order the delete reaches them. This object itself is named only when a cascading relation leads back to it. A `restrict` or `set_null` relation removes nothing and is not named. Read from the rule the delete runs, and object-level: it never says which records or how many. Present only on an `object` read answered by a process whose data engine answers it, and then `[]` when nothing cascades. Absent otherwise, and absence means no engine answered, never that nothing cascades. Unlike the protection keys it is published by the cached branch too, read live and folded into the ETag; it is absent on a draft read. Beside `item`, never inside it: it is derived from other objects' definitions and is not authorable. | | **draftChanges** | `{ path: string[]; by: Enum<'copilot' \| 'mcp' \| 'studio' \| 'api'>; actor: string \| null; client?: object; … }[]` | optional | Per-key provenance of the pending draft: which authoring surface last changed each key path of `item`, under which actor, and when. The draft save records it: each draft save is compared with the body that save replaced (the previous draft, or the stored published row for the draft's first save; a draft of an item with no stored published row is recorded as `[]`, the whole body). A `migrate-stored` rewrite of a draft row records nothing, since it is not authoring. The entries are kept from the first recorded save until the draft is published or discarded, which remove the draft row and the entries with it; and no two entries share a path: a save replaces every entry at or under each path it changes, so the last write to change a key is the entry whose `path` is the longest prefix of that key's path, and entries under a key's path are changes inside it. The entries name which writes changed what; they are not a list of every difference from the published body (compare the two bodies for that). Served only on a `?state=draft` read that answers a stored draft row. ABSENT on the active read, the cached branch and a `?preview=draft` read, and for a draft row whose saves recorded none: absence means "not recorded", never "no changes". | @@ -195,7 +195,7 @@ const result = AppMetadataBundleResponseSchema.parse(data); | **resettable** | `boolean` | optional | Whether the item can be reset to its packaged default — true iff it is artifact-backed, i.e. there is a baseline to reset TO. | | **version** | `string \| null` | optional | ADR-0008 version token of the STORED row a save to this item compares against, at this read's scope (the environment's partition and `?package=`) and lifecycle (`?state=draft` reads the draft row, the plain read the active row). The same keyed token a save receipt's `version` serves for that row: send it back as the `If-Match` request header on `PUT /meta/:type/:name` (with `?mode=draft` for the draft) and a concurrent edit is refused 409 `METADATA_CONFLICT` instead of overwritten. `null` when no stored row is there — an item served from code or a package artifact, or from a row in another scope (a package-less row a package read falls back to) — so the next save creates one: pin it with `If-None-Match: *`. A `null` beside `editable: false` is no such invitation: that item takes no save at this address, so no pin is prescribed for it. ABSENT on the cached published-value branch and on a `?preview=draft` read, which publish no version: absence means "not published here", never "no row". Opaque — echo it verbatim, never parse it. | | **registration** | `{ state: 'registered' } \| { state: 'refused'; reason: object } \| { state: 'unregistered' }` | optional | The automation engine's verdict on this flow (see `FlowRegistrationSchema`): `registered`, or `refused` with the engine's `reason` verbatim, or `unregistered`. Present only on a `flow` read answered by a process that runs an automation service; absent otherwise, and absence means no engine judged it, never `registered`. Unlike the protection keys it is published by the cached branch too, read live and never part of the ETag, so a cached read that carries it is never answered 304; it is absent on a draft read, whose pending body no engine holds. The verdict is the answering process's engine. Beside `item`, never inside it: the item's `status` stays what its author declared. | -| **disabledActions** | `string[]` | optional | The names in `item.actions` that this deployment's activation ledger switches off (an administrator turned them off on the action, in its package in Studio): a call to any of them is refused 409 `ACTION_DISABLED`. Present only on an `object` read answered by a process whose data engine has an activation ledger attached, and then `[]` when none of this object's actions is switched off. Absent otherwise, and absence means no ledger answered, never that nothing is switched off. Unlike the protection keys it is published by the cached branch too, read live and folded into the ETag, so a cached read revalidates to 304 only while the switched-off set is unchanged; it is absent on a draft read. The ledger is the answering process's engine's. Beside `item`, never inside it: `item.actions` is served as declared, a switched-off action included. | +| **disabledActions** | `string[]` | optional | The names in `item.actions` that this deployment's activation ledger switches off (an administrator turned them off through the activation door, for example on the action in Studio): a call to any of them is refused 409 `ACTION_DISABLED`. Present only on an `object` read answered by a process whose data engine has an activation ledger attached, and then `[]` when none of this object's actions is switched off. Absent otherwise, and absence means no ledger answered, never that nothing is switched off. Unlike the protection keys it is published by the cached branch too, read live and folded into the ETag, so a cached read revalidates to 304 only while the switched-off set is unchanged; it is absent on a draft read. The ledger is the answering process's engine's. Beside `item`, never inside it: `item.actions` is served as declared, a switched-off action included. | | **cascadeDeleteObjects** | `string[]` | optional | The objects, by name, that deleting a record of this object can also delete: every object whose relation into it cascades (a `master_detail` by default, a `lookup`, `tree` or `user` field that declares `deleteBehavior: 'cascade'`), and the objects that cascade into those in turn, each once, in the order the delete reaches them. This object itself is named only when a cascading relation leads back to it. A `restrict` or `set_null` relation removes nothing and is not named. Read from the rule the delete runs, and object-level: it never says which records or how many. Present only on an `object` read answered by a process whose data engine answers it, and then `[]` when nothing cascades. Absent otherwise, and absence means no engine answered, never that nothing cascades. Unlike the protection keys it is published by the cached branch too, read live and folded into the ETag; it is absent on a draft read. Beside `item`, never inside it: it is derived from other objects' definitions and is not authorable. | | **draftChanges** | `{ path: string[]; by: Enum<'copilot' \| 'mcp' \| 'studio' \| 'api'>; actor: string \| null; client?: object; … }[]` | optional | Per-key provenance of the pending draft: which authoring surface last changed each key path of `item`, under which actor, and when. The draft save records it: each draft save is compared with the body that save replaced (the previous draft, or the stored published row for the draft's first save; a draft of an item with no stored published row is recorded as `[]`, the whole body). A `migrate-stored` rewrite of a draft row records nothing, since it is not authoring. The entries are kept from the first recorded save until the draft is published or discarded, which remove the draft row and the entries with it; and no two entries share a path: a save replaces every entry at or under each path it changes, so the last write to change a key is the entry whose `path` is the longest prefix of that key's path, and entries under a key's path are changes inside it. The entries name which writes changed what; they are not a list of every difference from the published body (compare the two bodies for that). Served only on a `?state=draft` read that answers a stored draft row. ABSENT on the active read, the cached branch and a `?preview=draft` read, and for a draft row whose saves recorded none: absence means "not recorded", never "no changes". | diff --git a/content/docs/references/api/protocol.mdx b/content/docs/references/api/protocol.mdx index 63c016c2573..179e47fbc93 100644 --- a/content/docs/references/api/protocol.mdx +++ b/content/docs/references/api/protocol.mdx @@ -1530,7 +1530,7 @@ This schema accepts one of the following structures: | **resettable** | `boolean` | optional | Whether the item can be reset to its packaged default — true iff it is artifact-backed, i.e. there is a baseline to reset TO. | | **version** | `string \| null` | optional | ADR-0008 version token of the STORED row a save to this item compares against, at this read's scope (the environment's partition and `?package=`) and lifecycle (`?state=draft` reads the draft row, the plain read the active row). The same keyed token a save receipt's `version` serves for that row: send it back as the `If-Match` request header on `PUT /meta/:type/:name` (with `?mode=draft` for the draft) and a concurrent edit is refused 409 `METADATA_CONFLICT` instead of overwritten. `null` when no stored row is there — an item served from code or a package artifact, or from a row in another scope (a package-less row a package read falls back to) — so the next save creates one: pin it with `If-None-Match: *`. A `null` beside `editable: false` is no such invitation: that item takes no save at this address, so no pin is prescribed for it. ABSENT on the cached published-value branch and on a `?preview=draft` read, which publish no version: absence means "not published here", never "no row". Opaque — echo it verbatim, never parse it. | | **registration** | `{ state: 'registered' } \| { state: 'refused'; reason: object } \| { state: 'unregistered' }` | optional | The automation engine's verdict on this flow (see `FlowRegistrationSchema`): `registered`, or `refused` with the engine's `reason` verbatim, or `unregistered`. Present only on a `flow` read answered by a process that runs an automation service; absent otherwise, and absence means no engine judged it, never `registered`. Unlike the protection keys it is published by the cached branch too, read live and never part of the ETag, so a cached read that carries it is never answered 304; it is absent on a draft read, whose pending body no engine holds. The verdict is the answering process's engine. Beside `item`, never inside it: the item's `status` stays what its author declared. | -| **disabledActions** | `string[]` | optional | The names in `item.actions` that this deployment's activation ledger switches off (an administrator turned them off on the action, in its package in Studio): a call to any of them is refused 409 `ACTION_DISABLED`. Present only on an `object` read answered by a process whose data engine has an activation ledger attached, and then `[]` when none of this object's actions is switched off. Absent otherwise, and absence means no ledger answered, never that nothing is switched off. Unlike the protection keys it is published by the cached branch too, read live and folded into the ETag, so a cached read revalidates to 304 only while the switched-off set is unchanged; it is absent on a draft read. The ledger is the answering process's engine's. Beside `item`, never inside it: `item.actions` is served as declared, a switched-off action included. | +| **disabledActions** | `string[]` | optional | The names in `item.actions` that this deployment's activation ledger switches off (an administrator turned them off through the activation door, for example on the action in Studio): a call to any of them is refused 409 `ACTION_DISABLED`. Present only on an `object` read answered by a process whose data engine has an activation ledger attached, and then `[]` when none of this object's actions is switched off. Absent otherwise, and absence means no ledger answered, never that nothing is switched off. Unlike the protection keys it is published by the cached branch too, read live and folded into the ETag, so a cached read revalidates to 304 only while the switched-off set is unchanged; it is absent on a draft read. The ledger is the answering process's engine's. Beside `item`, never inside it: `item.actions` is served as declared, a switched-off action included. | | **cascadeDeleteObjects** | `string[]` | optional | The objects, by name, that deleting a record of this object can also delete: every object whose relation into it cascades (a `master_detail` by default, a `lookup`, `tree` or `user` field that declares `deleteBehavior: 'cascade'`), and the objects that cascade into those in turn, each once, in the order the delete reaches them. This object itself is named only when a cascading relation leads back to it. A `restrict` or `set_null` relation removes nothing and is not named. Read from the rule the delete runs, and object-level: it never says which records or how many. Present only on an `object` read answered by a process whose data engine answers it, and then `[]` when nothing cascades. Absent otherwise, and absence means no engine answered, never that nothing cascades. Unlike the protection keys it is published by the cached branch too, read live and folded into the ETag; it is absent on a draft read. Beside `item`, never inside it: it is derived from other objects' definitions and is not authorable. | | **draftChanges** | `{ path: string[]; by: Enum<'copilot' \| 'mcp' \| 'studio' \| 'api'>; actor: string \| null; client?: object; … }[]` | optional | Per-key provenance of the pending draft: which authoring surface last changed each key path of `item`, under which actor, and when. The draft save records it: each draft save is compared with the body that save replaced (the previous draft, or the stored published row for the draft's first save; a draft of an item with no stored published row is recorded as `[]`, the whole body). A `migrate-stored` rewrite of a draft row records nothing, since it is not authoring. The entries are kept from the first recorded save until the draft is published or discarded, which remove the draft row and the entries with it; and no two entries share a path: a save replaces every entry at or under each path it changes, so the last write to change a key is the entry whose `path` is the longest prefix of that key's path, and entries under a key's path are changes inside it. The entries name which writes changed what; they are not a list of every difference from the published body (compare the two bodies for that). Served only on a `?state=draft` read that answers a stored draft row. ABSENT on the active read, the cached branch and a `?preview=draft` read, and for a draft row whose saves recorded none: absence means "not recorded", never "no changes". | diff --git a/docs/adr/0146-studio-designs-setup-administers-one-editor-per-item-paired-customize-package.md b/docs/adr/0146-studio-designs-setup-administers-one-editor-per-item-paired-customize-package.md index 4407cc054da..a028fd27aaa 100644 --- a/docs/adr/0146-studio-designs-setup-administers-one-editor-per-item-paired-customize-package.md +++ b/docs/adr/0146-studio-designs-setup-administers-one-editor-per-item-paired-customize-package.md @@ -25,6 +25,7 @@ displacement cost. The amendment lands as the rewrite did — by the maintainer' a base's upgrade plan may report, as advice, each `.custom` override that hides a vendor change; `basedOn` still never gates, and nothing is refused, merged or rebased on the finding ([D2](#d2), [D6](#d6), the [Supersede table](#supersede-table)'s §9 row, [Consequences](#consequences), merge question 2). It lands by the maintainer's hand-merge of the PR cut from #30881. · **Amended in place** (2026-11-06, ruling record [`6691022506`](https://github.com/objectstack-ai/objectstack/issues/29594#issuecomment-6691022506) on [#29594](https://github.com/objectstack-ai/objectstack/issues/29594), maintainer, verbatim: 「① 定制单位 = App;同意」, and the second ruling record [`6691217245`](https://github.com/objectstack-ai/objectstack/issues/29594#issuecomment-6691217245) there, verbatim: 「内核白名单,可以下一版本再处理,首批名单建议:Users、Organizations;其他同意。」): the customization unit is the App, so there is one pair per App, `.custom`, shared by every package its artifact delivers and never one per module; the kernel is one platform suite with one platform pair, `com.objectstack.kernel.custom`, whose range is the platform version; no kernel object is customizable in this version, and the kernel whitelist (Users, Organizations) belongs to the next one ([D3](#d3), [D11](#d11), Q4, [Consequences](#consequences), merge questions 8 to 12); the App of a package is read from the declarations the registry holds, a package that declares no App is its own unit, and a pair created under the old per-package unit is re-identified as, or moved into, its App's pair by the migration ceremony (merge questions 11 and 12). It lands by the maintainer's hand-merge of the PR cut from #31014. +· **Amended in place** (2026-11-17, card [#34724](https://github.com/objectstack-ai/objectstack/issues/34724) of epic [#34571](https://github.com/objectstack-ai/objectstack/issues/34571), maintainer, verbatim: 「打包动作不是应该在 studio 对应的软件包中自定义吗」, and on platform actions getting no switch, 「同意,立卡」; ruling record [`6944409840`](https://github.com/objectstack-ai/objectstack/issues/34724#issuecomment-6944409840), verbatim: 「保持原状并写明恢复方法」): the action's ledger switch moves onto the action in Studio and Setup › Packaged Actions retires, so the line above that says D4 "keeps the ledger switch" now reads as the switch living in Studio; the platform's own actions carry no switch in the console, a row that already switches one off stays in force, and the activation door is the way to turn it on again ([D4](#d4), [D9](#d9)). It lands by the hand-merge or authorized approval of the PR cut from #34724. **Decided by**: the maintainer, 2026-10-30, in the desktop session that re-planned the epic, verbatim and untranslated as epic #28236 records them — the direction 「方向定为包级覆盖:代码和 Studio 用同一机制,定制都进 .custom。」; the suffix 「同意 后缀改成 .custom」; the eight questions 「等我拍板的 8 个问题,全部同意」; the extension fields 「扩展字段用 __c 后缀,只有 .custom 包能用。」; the item toolbar 「同意新增 2h「Studio 项工具栏」并放在 2a 之前」; @@ -594,8 +595,8 @@ naming the callers), the `FLOW_DISABLED` consult at `execute()`, and the walled (ADR-0126 §5). **`action`, the other Regime C type, takes the same shape later** (ruled 2026-10-31 on decision card #28364, in Q3's -pattern). Its precondition has landed: the action ledger switch is on `main` (#27842 and #27504, both closed 2026-10-30 — -outside this epic, [D4](#d4)). A declared override of a base's `action` is admitted, once its door is cut, under conditions 1–3 +pattern). Its precondition has landed: the action ledger switch is on `main` (#27842 and #27504, both closed 2026-10-30), and since +2026-11-17 it is drawn on the action in Studio ([D4](#d4) as amended, #34724). A declared override of a base's `action` is admitted, once its door is cut, under conditions 1–3 above read for an action: served over the code package's name, rebound in one reload, one ledger row for the name; condition 4 does not apply — an action has no suspended run. The door itself is not cut here: there is no override door for `action` yet, no interim gate, and no card of this epic opens one. An undeclared same-name `action` in a dependent is diff --git a/packages/objectql/src/action-activation.test.ts b/packages/objectql/src/action-activation.test.ts index 5da7988710b..8f4b6733cdf 100644 --- a/packages/objectql/src/action-activation.test.ts +++ b/packages/objectql/src/action-activation.test.ts @@ -33,6 +33,8 @@ import { describe, it, expect, vi } from 'vitest'; // INSIDE objectql, and the package re-exporting it is this one. import { assertEngineUpdateDispatch } from '@objectstack/metadata-core'; import { describeTurnedOffPackagedItem } from '@objectstack/types'; +import { READ_ONLY_PACKAGE_SCOPES } from '@objectstack/metadata-protocol'; +import { ACTION_KERNEL_PACKAGE_SCOPES } from './engine-actions.js'; import { ObjectQL } from './engine.js'; import { @@ -435,6 +437,12 @@ describe('ObjectQL engine — the projection the dispatch doors consult', () => expect(engine.describeDisabledAction('env_action')).toBe(describeTurnedOffPackagedItem('action')); }); + it('the kernel scope list the sentence reads is the one the package doors read', () => { + // Spelled locally because `./core` must not import metadata-protocol; + // a test may, and holds the two equal. + expect([...ACTION_KERNEL_PACKAGE_SCOPES].sort()).toEqual([...READ_ONLY_PACKAGE_SCOPES].sort()); + }); + it('setActionActive flips the row and the projection together, in that order', async () => { const engine = new ObjectQL(); const store = new InMemoryActionActivationStore(); diff --git a/packages/objectql/src/engine-actions.ts b/packages/objectql/src/engine-actions.ts index 4efb9d8433c..7a7b0c2f728 100644 --- a/packages/objectql/src/engine-actions.ts +++ b/packages/objectql/src/engine-actions.ts @@ -144,16 +144,17 @@ export interface ActionsHost { * The manifest scopes of a kernel package: the platform's own (`system`) and * the control plane's (`cloud`). The same list as `@objectstack/metadata-protocol`'s * `READ_ONLY_PACKAGE_SCOPES` and `@objectstack/metadata-core`'s - * `KERNEL_PACKAGE_SCOPES`; spelled here because this module is inside the + * `KERNEL_PACKAGE_SCOPES`, held equal to the first by a pin in + * `action-activation.test.ts`; spelled here because this module is inside the * `./core` closure, which must not import metadata-protocol (ADR-0076 D2, * `core-boundary.ratchet.test.ts`), and metadata-core does not export it. */ -const KERNEL_PACKAGE_SCOPES: readonly string[] = ['system', 'cloud']; +export const ACTION_KERNEL_PACKAGE_SCOPES: readonly string[] = ['system', 'cloud']; /** Is `manifest` a kernel package's — scope `system` or `cloud`? */ function isKernelPackageScope(manifest: unknown): boolean { const scope = (manifest as { scope?: unknown } | null | undefined)?.scope; - return typeof scope === 'string' && KERNEL_PACKAGE_SCOPES.includes(scope); + return typeof scope === 'string' && ACTION_KERNEL_PACKAGE_SCOPES.includes(scope); } /** The bodies of the "Action system and packaged-action activation" section of `ObjectQL`: a stateless facet, called by the class's stubs. */ diff --git a/packages/objectql/src/engine.ts b/packages/objectql/src/engine.ts index 4a65fa8fa35..333eee8cb77 100644 --- a/packages/objectql/src/engine.ts +++ b/packages/objectql/src/engine.ts @@ -1236,6 +1236,12 @@ export class ObjectQL implements IObjectQLEngine { * is the one place every refusal passes that holds the host's logger. It is * `info`, not `warn`: the refusal is handed to the caller, and nothing is * degraded (AGENTS.md "Degradation log levels"). + * + * [#34724, ruling 6944409840] There are two sentences. An app's action is + * turned on again on the action in Studio. A platform action (its ledger + * row names a package whose installed manifest has scope `system` or + * `cloud`) has no switch in Studio, so its sentence names the activation + * door instead. */ describeDisabledAction(actionName: string): string { // [#29986 codemod] The body moved to `engine-actions.ts` (see `ActionsHost`). diff --git a/packages/spec/src/api/protocol.zod.ts b/packages/spec/src/api/protocol.zod.ts index d5ce545a9a6..0b9eda6a936 100644 --- a/packages/spec/src/api/protocol.zod.ts +++ b/packages/spec/src/api/protocol.zod.ts @@ -791,9 +791,10 @@ export const GetMetaItemResponseSchema = lazySchema(() => z.object({ ), disabledActions: z.array(z.string()).optional().describe( 'The names in `item.actions` that this deployment\'s activation ledger switches off (an administrator ' - + 'turned them off on the action, in its package in Studio): a call to any of them is refused 409 ' - + '`ACTION_DISABLED`. Present only on an `object` read answered by a process whose data engine has an ' - + 'activation ledger attached, and then `[]` when none of this object\'s actions is switched off. ' + + 'turned them off through the activation door, for example on the action in Studio): a call to any of ' + + 'them is refused 409 `ACTION_DISABLED`. Present only on an `object` read answered by a process ' + + 'whose data engine has an activation ledger attached, and then `[]` when none of this object\'s ' + + 'actions is switched off. ' + 'Absent otherwise, and absence means no ledger answered, never that nothing is switched off. Unlike ' + 'the protection keys it is published by the cached branch too, read live and folded into the ETag, ' + 'so a cached read revalidates to 304 only while the switched-off set is unchanged; it is absent on ' diff --git a/ui/packages/app-shell/src/views/metadata-admin/ResourceEditPage.actionLedgerSwitch-34724.test.tsx b/ui/packages/app-shell/src/views/metadata-admin/ResourceEditPage.actionLedgerSwitch-34724.test.tsx index e252eb198ec..523edb5ceb6 100644 --- a/ui/packages/app-shell/src/views/metadata-admin/ResourceEditPage.actionLedgerSwitch-34724.test.tsx +++ b/ui/packages/app-shell/src/views/metadata-admin/ResourceEditPage.actionLedgerSwitch-34724.test.tsx @@ -18,7 +18,7 @@ import * as React from 'react'; // (`check:test-source-alias`). import '@objectstack/lint'; import { describe, it, expect, vi, afterEach, beforeEach } from 'vitest'; -import { render, screen, cleanup, fireEvent, waitFor } from '@testing-library/react'; +import { render, screen, cleanup, fireEvent, waitFor, act } from '@testing-library/react'; import { MemoryRouter } from 'react-router-dom'; import { MetadataAreaHostContext, type MetadataAreaHost } from './metadataAreaHost'; @@ -154,6 +154,20 @@ describe("a standalone action's item page carries the ledger switch (objectstack openItem(hostOf(KERNEL)); await screen.findByTestId('package-readonly-banner'); await waitFor(() => expect(vi.mocked(fetchPackages)).toHaveBeenCalled()); + for (let i = 0; i < 5; i++) await act(async () => { await new Promise((r) => setTimeout(r, 0)); }); + expect(vi.mocked(fetch).mock.calls.filter(([url]) => String(url).includes('sys_metadata_activation'))).toHaveLength(0); + expect(screen.queryByTestId('action-ledger-switch')).toBeNull(); + }); + + it('an app area showing an item a kernel package ships judges the item\'s package: no switch', async () => { + layered = { ...layered, packageId: KERNEL }; + openItem(hostOf(APP)); + await screen.findByTestId('package-readonly-banner'); + await waitFor(() => expect(vi.mocked(fetchPackages)).toHaveBeenCalled()); + // Let the package verdict and any ledger read settle before reading absence. + for (let i = 0; i < 5; i++) await act(async () => { await new Promise((r) => setTimeout(r, 0)); }); + const ledgerReads = vi.mocked(fetch).mock.calls.filter(([url]) => String(url).includes('sys_metadata_activation')); + expect(ledgerReads).toHaveLength(0); expect(screen.queryByTestId('action-ledger-switch')).toBeNull(); }); diff --git a/ui/packages/app-shell/src/views/metadata-admin/ResourceEditPage.tsx b/ui/packages/app-shell/src/views/metadata-admin/ResourceEditPage.tsx index 96979aef962..e46dfb0b9d4 100644 --- a/ui/packages/app-shell/src/views/metadata-admin/ResourceEditPage.tsx +++ b/ui/packages/app-shell/src/views/metadata-admin/ResourceEditPage.tsx @@ -3261,7 +3261,10 @@ function MetadataResourceEditPageImpl({ )} {hostReadOnly && !createMode && type === 'action' && areaHost?.packageId && ( - + // The package that ships the item when the read names it, the + // area's otherwise: an app's area can show an item another + // package ships, and a kernel-shipped one gets no switch. + )} {readOnly && !hostReadOnly && !isLocked && !canAuthor && !walledDeciding && !declarationOnly && (
{ if (!busy) onToggle(); }} diff --git a/ui/packages/app-shell/src/views/studio-design/ObjectActionsPanel.tsx b/ui/packages/app-shell/src/views/studio-design/ObjectActionsPanel.tsx index 5034f9f6a3d..bba87522e3e 100644 --- a/ui/packages/app-shell/src/views/studio-design/ObjectActionsPanel.tsx +++ b/ui/packages/app-shell/src/views/studio-design/ObjectActionsPanel.tsx @@ -219,7 +219,8 @@ export function ObjectActionsPanel({ // objectstack#34724 — the ledger switch of a read-only package's vendor // actions. The package is the route's: on a read-only package's object the // vendor actions are that package's own. A writable package's actions are - // the draft's, switched by editing them, so nothing is read there. + // the draft's: the console draws no ledger switch there (the card's item 1 + // offers it on a read-only app's vendor actions only), so nothing is read. const routePackage = useParams<{ packageId?: string }>().packageId ?? null; const ledgerPackage = disabled && routePackage && !isStudioOrgScope(routePackage) ? routePackage : null; From c0b10b3a1863e8aedd019f9e381790affd0f970c Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 17 Nov 2026 11:19:37 +0000 Subject: [PATCH 03/12] docs(reference): regenerate the protocol reference after merging main Co-Authored-By: Claude Claude-Session: https://claude.ai/code/session_01WGufziD6XhBNH9acXaG2Me --- content/docs/references/api/protocol.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/content/docs/references/api/protocol.mdx b/content/docs/references/api/protocol.mdx index 179e47fbc93..6cd9e3e3c87 100644 --- a/content/docs/references/api/protocol.mdx +++ b/content/docs/references/api/protocol.mdx @@ -3004,7 +3004,7 @@ Answer to a device registration: the device id the client keeps | **actor** | `string` | optional | Identity recorded on the write's history event (`recorded_by`, a lookup into `sys_user`) and audit row. On the REST door this is the request's authenticated identity (one producer) — never a caller-supplied header. Absent, the event is recorded actor-less (null), deliberately not attributed to "system". | | **force** | `boolean` | optional | Destructive-change acknowledgement (`?force=true` on the REST door): skips the safety diff that refuses an `object` save whose body drops fields or narrows types the stored item still carries (409 with the findings otherwise). Only `object` saves reach that diff, so the flag is inert for every other type. Absent = the guard runs. | | **mode** | `Enum<'draft' \| 'publish'>` | optional | Per-item lifecycle (ADR-0005 drafts): `draft` stages the body as a pending draft overlay (`?mode=draft` on the REST door; the publish door promotes it later); `publish` or ABSENT writes straight to the live `active` row — the legacy default, kept so callers that predate the draft/publish split keep working. Any value other than `draft` is read as `publish`. | -| **packageId** | `string \| null` | optional | ADR-0048 — the software package to bind the saved row to (`sys_metadata.package_id`; `?package=` on the REST door, where `all` and an empty value name no package). Set when authoring inside a Studio package workspace; a named read-only base package is refused. On create the row is stamped with this id; on update an existing binding is preserved, never silently re-bound. Absent or `null` names no package. An `active` save then writes the row of the one package the item's active rows are bound to, as a save naming that package does, is refused `409 RESOURCE_CONFLICT` when they are bound to two or more, and with none writes the env-local overlay (no package stamp); a `draft` save writes the draft of the one package the item's active rows are bound to (a pending change stays in the package it edits), else its package-unbound draft, adopted into that package — the draft the per-item publish naming no package promotes. For an item never published into a package it is the package-unbound draft, else the one package's draft, and with no draft at all the save creates the package-unbound draft. It is refused `409 RESOURCE_CONFLICT` when the active rows (or, with none and no package-unbound draft, the drafts) are bound to two or more packages, as that publish is (see `PublishMetaItemRequestSchema.packageId`). The row written is also the one the parent-version resolution reads: an unpinned save takes its version as the parent (last-write-wins), a pinned one is judged against it, and the item read at the same scope serves it as `version`. | +| **packageId** | `string \| null` | optional | ADR-0048 — the software package to bind the saved row to (`sys_metadata.package_id`; `?package=` on the REST door, where `all` and an empty value name no package). Set when authoring inside a Studio package workspace; a named read-only base package is refused. On create the row is stamped with this id; on update an existing binding is preserved, never silently re-bound. Absent or `null` names no package. An `active` save then writes the row of the one package the item's active rows are bound to, as a save naming that package does, is refused `409 RESOURCE_CONFLICT` when they are bound to two or more, and with none writes the env-local overlay (no package stamp); a `draft` save writes the draft of the one package the item's active rows are bound to (a pending change stays in the package it edits), else its package-unbound draft, adopted into that package — the draft the per-item publish naming no package promotes. For an item never published into a package it is the package-unbound draft, else the one package's draft, and with no draft at all the save creates the package-unbound draft. It is refused `409 RESOURCE_CONFLICT` when the active rows (or, with none and no package-unbound draft, the drafts) are bound to two or more packages, as that publish is (see `PublishMetaItemRequestSchema.packageId`). An `action` is keyed by the object it binds (ADR-0150 D4): when one or more packages' active rows hold the name and none of those rows binds the object the body binds (object-less is its own key), the save writes the environment's own package-unbound row (`active`) or draft (`draft`), never a package's item. The environment keeps one package-unbound row and one package-unbound draft per action name: such a save over the environment's own row or draft bound to another object rewrites it onto the body's object, and over one bound to an object a package's active row binds (that package's customization) it is refused `409 RESOURCE_CONFLICT`; a `draft` save is refused the same way when the package-unbound row its publish would rewrite is that customization. Otherwise the address above stands, judged over every holder of the name (every enabled holder, for an `active` save), except that an `active` save is judged over the holders at the body's object only when a disabled package is one of them and another holder binds another object. The per-item publish and the draft discard naming no package act on the environment's draft so written, except that with one package holding the name, that package's own draft, when one is stored, comes first; that publish is refused `409 RESOURCE_CONFLICT` when the package-unbound row it would rewrite is a package's customization. Until the read naming no package keys an action by object, the version it serves is the package's item's, so a save carrying it as the parent is refused as a version conflict. The row written is also the one the parent-version resolution reads: an unpinned save takes its version as the parent (last-write-wins), a pinned one is judged against it, and the item read at the same scope serves it as `version`. | | **writeFace** | `Enum<'package-duplicate' \| 'meta-envelope' \| 'meta-dispatch' \| 'external-import'>` | optional | Which write door a refusal is being rendered FOR — stated by the SERVER, never by a remote caller: every door builds this request field by field and never spreads a request body into it, so there is no path for a client to smuggle a face in, and a face arriving in a wire body is simply never read. Two refusals branch on it, for different questions: the 409 destructive-change remedy names the acknowledgement mechanism that actually exists on the refusing door (`?force=true` on the REST doors; the dispatcher, the duplicate-package door and the external-table import have none), and the 422 invalid-metadata message adapts to whether a structured `issues[]` channel reaches the consumer beside it. Absent = the conservative default wording. | | **surface** | `Enum<'copilot' \| 'mcp' \| 'studio' \| 'api'>` | optional | The authoring surface this save is made through (see `MetadataAuthoringSurfaceSchema`). A draft save (`mode: 'draft'`) stamps it as `by` on every key path it changes, the entries the strict draft read serves as `draftChanges`; an active save records no per-key provenance. ABSENT stamps `api`. On the REST door and the runtime dispatcher it is the `?surface=` query parameter, which takes `studio` or `api` and refuses every other value `400 VALIDATION_ERROR`, `copilot` and `mcp` included: `copilot` is stated only by an in-process AI tool calling the save and `mcp` only by the MCP build door after it verified the client's token, never by a remote caller, so an HTTP request cannot mark its own write as the copilot's or an MCP agent's. A value outside the set in-process is refused `400 INVALID_REQUEST`, before anything is written. | | **client** | `{ id: string; name?: string }` | optional | The OAuth client this save is made by (see `MetadataAuthoringClientSchema`), stated only by the MCP build door, in-process, from the token it verified. Only with `surface: 'mcp'`: a `client` beside any other surface, or a malformed one, is refused `400 INVALID_REQUEST` before anything is written. A draft save stamps it as `client` beside `by: 'mcp'` on every key path it changes; an active save records it nowhere. No HTTP door reads it: the REST door and the dispatcher build this request member by member, so a `client` in a wire body or query is never read. | From b1c4a7b3f041c5e709e6f8968f29a873933d945c Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 17 Nov 2026 11:19:38 +0000 Subject: [PATCH 04/12] feat(studio): the landing's switched-off count leads to the switched-off actions A base whose switched-off items are all actions opens the action's page in the All metadata area (one action) or the action list (several); with flows among them, the count still opens Automations and a second link opens the actions. Co-Authored-By: Claude Claude-Session: https://claude.ai/code/session_01WGufziD6XhBNH9acXaG2Me --- ...Landing.customizationCounts-28566.test.tsx | 82 +++++++++++++++++++ .../views/studio-design/BuilderLanding.tsx | 40 ++++++++- .../studio-design/packageCustomizations-io.ts | 17 +++- ui/packages/i18n/src/namespaces/studio/en.ts | 2 + ui/packages/i18n/src/namespaces/studio/zh.ts | 2 + 5 files changed, 138 insertions(+), 5 deletions(-) diff --git a/ui/packages/app-shell/src/views/studio-design/BuilderLanding.customizationCounts-28566.test.tsx b/ui/packages/app-shell/src/views/studio-design/BuilderLanding.customizationCounts-28566.test.tsx index 4009702538e..b8de7583257 100644 --- a/ui/packages/app-shell/src/views/studio-design/BuilderLanding.customizationCounts-28566.test.tsx +++ b/ui/packages/app-shell/src/views/studio-design/BuilderLanding.customizationCounts-28566.test.tsx @@ -95,6 +95,7 @@ function renderLanding() { } /> } /> + } /> , ); @@ -234,6 +235,87 @@ describe('Studio landing: a read-only base says "n customized, m switched off" ( * switcher folds it, and the base's card carries it through its customized * line and link. The pair's export and delete stay on the Packages page. */ +/** A served answer for `id` whose switched-off items are exactly `items`. */ +function servedOff(id: string, items: Array<{ type: string; name: string }>) { + const data = { + packageId: id, + overrides: [], + extensions: [], + switchedOff: items, + contributions: [], + counts: { overrides: 0, extensions: 0, switchedOff: items.length, contributions: 0 }, + }; + return { status: 200, body: { success: true, data } }; +} + +describe('Studio landing: "m switched off" leads to the switched-off actions (objectstack#34724)', () => { + async function readLine() { + const line = await within(await waitFor(() => cardOf('Showcase'))).findByTestId('studio-landing-customizations'); + await waitFor(() => expect(line).toHaveAttribute('data-state', 'read')); + return line; + } + + it('one switched-off action: the count opens that action\'s page, where its switch reads off', async () => { + packages.list = [SHOWCASE]; + stubWire({ 'com.example.showcase': servedOff('com.example.showcase', [{ type: 'action', name: 'showcase_mark_done' }]) }); + renderLanding(); + const line = await readLine(); + const off = within(line).getByTestId('studio-landing-customizations-switched-off'); + expect(off).toHaveTextContent(switchedOffText(1)); + expect(off).toHaveAttribute('href', '/studio/com.example.showcase/metadata/action/showcase_mark_done'); + expect(off).toHaveAttribute('title', t('engine.studio.landing.customizations.switchedOffActionsTitle', 'en-US')); + expect(within(line).queryByTestId('studio-landing-customizations-switched-off-actions')).not.toBeInTheDocument(); + }); + + it('several switched-off actions: the count opens the action list', async () => { + packages.list = [SHOWCASE]; + stubWire({ + 'com.example.showcase': servedOff('com.example.showcase', [ + { type: 'action', name: 'showcase_mark_done' }, + { type: 'action', name: 'showcase_portfolio_snapshot' }, + ]), + }); + renderLanding(); + const off = within(await readLine()).getByTestId('studio-landing-customizations-switched-off'); + expect(off).toHaveAttribute('href', '/studio/com.example.showcase/metadata/action'); + }); + + it('flows and actions switched off: the count opens Automations, and a second link the actions', async () => { + packages.list = [SHOWCASE]; + stubWire({ + 'com.example.showcase': servedOff('com.example.showcase', [ + { type: 'action', name: 'showcase_mark_done' }, + { type: 'flow', name: 'showcase_nightly' }, + ]), + }); + renderLanding(); + const line = await readLine(); + expect(within(line).getByTestId('studio-landing-customizations-switched-off')).toHaveAttribute( + 'href', + '/studio/com.example.showcase/automations', + ); + const actions = within(line).getByTestId('studio-landing-customizations-switched-off-actions'); + expect(actions).toHaveTextContent(tFormat('engine.studio.landing.customizations.switchedOffActions', 'en-US', { count: 1 })); + expect(actions).toHaveAttribute('href', '/studio/com.example.showcase/metadata/action/showcase_mark_done'); + fireEvent.click(actions); + await waitFor(() => + expect(screen.getByTestId('location')).toHaveTextContent('/studio/com.example.showcase/metadata/action/showcase_mark_done'), + ); + }); + + it('flows only: the count opens Automations, with no actions link (unchanged)', async () => { + packages.list = [SHOWCASE]; + stubWire({ 'com.example.showcase': servedOff('com.example.showcase', [{ type: 'flow', name: 'showcase_nightly' }]) }); + renderLanding(); + const line = await readLine(); + expect(within(line).getByTestId('studio-landing-customizations-switched-off')).toHaveAttribute( + 'href', + '/studio/com.example.showcase/automations', + ); + expect(within(line).queryByTestId('studio-landing-customizations-switched-off-actions')).not.toBeInTheDocument(); + }); +}); + describe('Studio landing: a base’s .custom pair has no card of its own (ADR-0146 D3)', () => { /** Every package card the landing draws, by the package id each card carries. */ const cardIds = () => diff --git a/ui/packages/app-shell/src/views/studio-design/BuilderLanding.tsx b/ui/packages/app-shell/src/views/studio-design/BuilderLanding.tsx index bb5b807136b..ceab349d206 100644 --- a/ui/packages/app-shell/src/views/studio-design/BuilderLanding.tsx +++ b/ui/packages/app-shell/src/views/studio-design/BuilderLanding.tsx @@ -68,6 +68,17 @@ type CustomizationLine = const studioPillarPath = (packageId: string, pillar: 'data' | 'automations') => `/studio/${encodeURIComponent(packageId)}/${pillar}`; +/** + * objectstack#34724 (ADR-0146 D4 as amended 2026-11-17) — where a base's + * switched-off actions are switched on again: an action's switch is on the + * action in Studio. One action opens its own page in the "All metadata" area, + * where the switch reads off; more than one opens that area's action list. + */ +const switchedOffActionsPath = (packageId: string, actions: readonly string[]) => { + const list = `/studio/${encodeURIComponent(packageId)}/metadata/action`; + return actions.length === 1 ? `${list}/${encodeURIComponent(actions[0])}` : list; +}; + export function BuilderLanding(): React.ReactElement { const navigate = useNavigate(); const locale = useMetadataLocale(); @@ -254,6 +265,13 @@ export function BuilderLanding(): React.ReactElement { customized: line.counts.customized, }); const linkClass = 'hover:text-foreground hover:underline'; + // objectstack#34724 — the "switched off" count leads to the items: a flow's + // switch is in the Automations pillar, an action's on the action. When + // every switched-off item is an action, the count opens them; when flows + // are among them too, the count opens Automations and a second link the + // actions. + const offActions = line.counts.switchedOffActions ?? []; + const offOnlyActions = offActions.length > 0 && offActions.length === line.counts.switchedOff; return (

{pair ? ( @@ -270,8 +288,13 @@ export function BuilderLanding(): React.ReactElement { )} {t('engine.studio.landing.customizations.separator', locale)} @@ -279,6 +302,19 @@ export function BuilderLanding(): React.ReactElement { switchedOff: line.counts.switchedOff, })} + {offActions.length > 0 && !offOnlyActions && ( + <> + {' '} + + {tFormat('engine.studio.landing.customizations.switchedOffActions', locale, { count: offActions.length })} + + + )}

); }; diff --git a/ui/packages/app-shell/src/views/studio-design/packageCustomizations-io.ts b/ui/packages/app-shell/src/views/studio-design/packageCustomizations-io.ts index 35f1c596a11..067b9dcd513 100644 --- a/ui/packages/app-shell/src/views/studio-design/packageCustomizations-io.ts +++ b/ui/packages/app-shell/src/views/studio-design/packageCustomizations-io.ts @@ -32,12 +32,19 @@ import { import { isCustomizationPackage } from '@objectstack/spec/kernel'; import { readEnvelopeFailureText } from '../../utils/apiErrorEnvelope.js'; -/** What the landing draws for one base: two served numbers. */ +/** What the landing draws for one base: two served numbers, and which switched-off items are actions. */ export interface PackageCustomizationCounts { /** Served overrides plus served extensions of the base's pair. */ customized: number; /** Served switched-off items of the base. */ switchedOff: number; + /** + * objectstack#34724 — the names of the switched-off items that are + * actions, in the served order: the landing's "switched off" link leads to + * them, since an action's switch is on the action in Studio. Absent reads + * as none. + */ + switchedOffActions?: readonly string[]; } /** The route of the read, for one base package id. */ @@ -84,6 +91,10 @@ export async function fetchPackageCustomizations(baseId: string): Promise { - const { counts } = await fetchPackageCustomizations(baseId); - return { customized: counts.overrides + counts.extensions, switchedOff: counts.switchedOff }; + const { counts, switchedOff } = await fetchPackageCustomizations(baseId); + return { + customized: counts.overrides + counts.extensions, + switchedOff: counts.switchedOff, + switchedOffActions: switchedOff.filter((item) => item.type === 'action').map((item) => item.name), + }; } diff --git a/ui/packages/i18n/src/namespaces/studio/en.ts b/ui/packages/i18n/src/namespaces/studio/en.ts index af5971708fa..128a7c324ca 100644 --- a/ui/packages/i18n/src/namespaces/studio/en.ts +++ b/ui/packages/i18n/src/namespaces/studio/en.ts @@ -3427,6 +3427,8 @@ const STUDIO_EN: Record = { 'engine.studio.landing.customizations.failed': 'Couldn’t read customizations', 'engine.studio.landing.customizations.pairTitle': 'Open the customization package {pair} in Studio', 'engine.studio.landing.customizations.switchedOffTitle': 'Open this package’s Automations, where its items are switched on and off', + 'engine.studio.landing.customizations.switchedOffActions': '(actions: {count})', + 'engine.studio.landing.customizations.switchedOffActionsTitle': 'Open the switched-off actions: each one is switched on again on the action', // objectui#11553 — the package-less scope: the organization's own flows. 'engine.studio.landing.orgHeading': 'Not in a package', 'engine.studio.org.name': 'Organization flows', diff --git a/ui/packages/i18n/src/namespaces/studio/zh.ts b/ui/packages/i18n/src/namespaces/studio/zh.ts index 5dd82425a72..902effbf2e9 100644 --- a/ui/packages/i18n/src/namespaces/studio/zh.ts +++ b/ui/packages/i18n/src/namespaces/studio/zh.ts @@ -3023,6 +3023,8 @@ const STUDIO_ZH: Record = { 'engine.studio.landing.customizations.failed': '无法读取定制', 'engine.studio.landing.customizations.pairTitle': '在 Studio 中打开定制包 {pair}', 'engine.studio.landing.customizations.switchedOffTitle': '打开该软件包的自动化,在那里启用或停用其中的项', + 'engine.studio.landing.customizations.switchedOffActions': '(其中动作 {count} 项)', + 'engine.studio.landing.customizations.switchedOffActionsTitle': '打开已停用的动作:在动作上即可重新启用', // objectui#11553 — the package-less scope: the organization's own flows. 'engine.studio.landing.orgHeading': '不属于软件包', 'engine.studio.org.name': '组织流程', From 84f0666c22d5ab290e8744dd809903f630651f27 Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 17 Nov 2026 11:26:29 +0000 Subject: [PATCH 05/12] test: count the retired Packaged Actions entry out of Setup's served tree, and declare its redirect route's reads The Setup tree the connect-agent wire pin counts loses nav_packaged_actions and the group_apps group it alone held there (33 -> 31). The console's packaged-actions redirect route carries a NONE row in APP_ROUTE_METADATA_READS, like the retired Packaged automation redirect. Co-Authored-By: Claude Claude-Session: https://claude.ai/code/session_01WGufziD6XhBNH9acXaG2Me --- .../connect-agent-both-halves-wire.pin.test.ts | 18 +++++++++++------- .../src/console/appRouteMetadataReads.ts | 2 ++ 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/packages/cli/test/connect-agent-both-halves-wire.pin.test.ts b/packages/cli/test/connect-agent-both-halves-wire.pin.test.ts index 7f5013d1c1a..6f5fdbc2771 100644 --- a/packages/cli/test/connect-agent-both-halves-wire.pin.test.ts +++ b/packages/cli/test/connect-agent-both-halves-wire.pin.test.ts @@ -259,22 +259,26 @@ describe('#17647 — Connect-an-Agent visibility: BOTH halves, over the wire', ( expect(groupChildren(setupAllowed.body?.item, 'group_overview')) .toEqual(['nav_system_overview', 'nav_connect_agent']); // The Setup tree the platform admin is served BY THIS COMPOSITION: 9 - // authored groups less `group_approvals` and `group_integrations`, - // which nothing in it contributes into and the filter collapses, plus - // the 25 entries `SETUP_NAV_CONTRIBUTIONS` carries, plus the MCP one. + // authored groups less `group_approvals`, `group_integrations` and + // `group_apps`, which nothing in it contributes into and the filter + // collapses, plus the 24 entries `SETUP_NAV_CONTRIBUTIONS` carries, + // plus the MCP one. // (25 until #25098 moved the unfiltered Packages entry to Studio; 24 // until #30204 removed the Feature Flags entry with its namespace; 32 // until #30895 moved the MCP entry out of `group_integrations`, the // one entry this composition put there; 31 until the organization // Access policy entry, `nav_settings_access_policy`, joined // Configuration; 32 until the recycle bin entry, `nav_recycle_bin`, - // joined Configuration (#30239).) + // joined Configuration (#30239); 33 until objectstack#34724 retired + // the Packaged Actions entry, `nav_packaged_actions`, the one entry + // `group_apps` held here, so that group collapses too.) // `nav_settings_branding` is not among them, and not because of a // tenancy wall (this harness boots none): since #24766 it is // contributed by `@objectstack/service-settings` together with the // `branding` namespace, offered only where no organization wall stands, // and this harness composes platform-objects and the MCP bundle alone. - expect(allowedIds).toHaveLength(33); + expect(allowedIds).toHaveLength(31); + expect(allowedIds).not.toContain('nav_packaged_actions'); expect(allowedIds).toContain('nav_settings_access_policy'); expect(allowedIds).toContain('nav_recycle_bin'); expect(allowedIds).not.toContain('nav_settings_branding'); @@ -299,8 +303,8 @@ describe('#17647 — Connect-an-Agent visibility: BOTH halves, over the wire', ( expect(withAccountHalf.statusCode).toBe(200); expect(withoutAccountHalf.statusCode).toBe(200); expect(navIds(withAccountHalf.body?.item)).toEqual(navIds(withoutAccountHalf.body?.item)); - // 33: the composition the count in the test above states. - expect(navIds(withAccountHalf.body?.item)).toHaveLength(33); + // 31: the composition the count in the test above states. + expect(navIds(withAccountHalf.body?.item)).toHaveLength(31); // The mechanism behind the invariance, asserted rather than assumed: // the bundle aims exactly one contribution at `setup` and one at diff --git a/ui/packages/app-shell/src/console/appRouteMetadataReads.ts b/ui/packages/app-shell/src/console/appRouteMetadataReads.ts index c643467fff0..6e6dd5f115e 100644 --- a/ui/packages/app-shell/src/console/appRouteMetadataReads.ts +++ b/ui/packages/app-shell/src/console/appRouteMetadataReads.ts @@ -74,6 +74,8 @@ export const APP_ROUTE_METADATA_READS: ReadonlyArray<{ path: string; reads: read { path: 'component/:ns/:name/*', reads: ALL_LAZY_METADATA_TYPES }, // A redirect into Studio (objectstack#28578): the retired Packaged automation page. { path: 'component/automation/packaged', reads: NONE }, + // A redirect into Studio (objectstack#34724): the retired Packaged Actions page. + { path: 'component/automation/packaged-actions', reads: NONE }, { path: 'component/metadata/directory', reads: NONE }, { path: 'component/metadata/resource/*', reads: NONE }, { path: 'design/dashboard/:dashboardName', reads: ['dashboard'] }, From d6b8707b0aa7841d23b6c837a557c2a63c387710 Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 17 Nov 2026 11:45:45 +0000 Subject: [PATCH 06/12] feat(studio): the landing line names each switched-off action as a link to its page The action list a several-actions count opens marks none of them, so when the count alone does not land on an action (several, or flows among them) the line names each switched-off action, three at most, as a link to its own page, then a "more" link to the list. Co-Authored-By: Claude Claude-Session: https://claude.ai/code/session_01WGufziD6XhBNH9acXaG2Me --- .../34724-action-switch-moves-to-studio.md | 1 + ...Landing.customizationCounts-28566.test.tsx | 49 +++++++++++++--- .../views/studio-design/BuilderLanding.tsx | 57 ++++++++++++++----- ui/packages/i18n/src/namespaces/studio/en.ts | 3 +- ui/packages/i18n/src/namespaces/studio/zh.ts | 3 +- 5 files changed, 88 insertions(+), 25 deletions(-) diff --git a/.changeset/34724-action-switch-moves-to-studio.md b/.changeset/34724-action-switch-moves-to-studio.md index ffccf41467a..38e7a9a479f 100644 --- a/.changeset/34724-action-switch-moves-to-studio.md +++ b/.changeset/34724-action-switch-moves-to-studio.md @@ -21,6 +21,7 @@ Before this change, the deployment's on/off switch for an installed app's action - On the object's Actions view in Studio, a read-only app package's vendor action carries a "Switched on / off for this deployment" switch, the flow switch's twin. A switched-off action is marked in the list. A refusal is the server's sentence, shown verbatim; a caller the deployment's posture walls off sees the switch disabled with the reason. - A standalone `action` item's page in Studio's "All metadata" area carries the same switch. - The platform's own actions (any action a kernel package ships) carry no switch anywhere. When the package list cannot be read, no switch is offered. +- Studio's landing leads to them: an app's "N switched off" count opens the switched-off action itself (one) or the action list (several), and when that does not land on an action (several, or flows among them), the line names each switched-off action as a link to its page, three at most, then a "more" link to the list. The doors are unchanged: the read is the `sys_metadata_activation` ledger, the write is `POST /api/v1/actions/_activation/:object/:action` with body `{ enabled }`. diff --git a/ui/packages/app-shell/src/views/studio-design/BuilderLanding.customizationCounts-28566.test.tsx b/ui/packages/app-shell/src/views/studio-design/BuilderLanding.customizationCounts-28566.test.tsx index b8de7583257..6631e4e77f8 100644 --- a/ui/packages/app-shell/src/views/studio-design/BuilderLanding.customizationCounts-28566.test.tsx +++ b/ui/packages/app-shell/src/views/studio-design/BuilderLanding.customizationCounts-28566.test.tsx @@ -267,7 +267,7 @@ describe('Studio landing: "m switched off" leads to the switched-off actions (ob expect(within(line).queryByTestId('studio-landing-customizations-switched-off-actions')).not.toBeInTheDocument(); }); - it('several switched-off actions: the count opens the action list', async () => { + it('several switched-off actions: the count opens the action list, and the line names each one as a link to its page', async () => { packages.list = [SHOWCASE]; stubWire({ 'com.example.showcase': servedOff('com.example.showcase', [ @@ -276,11 +276,43 @@ describe('Studio landing: "m switched off" leads to the switched-off actions (ob ]), }); renderLanding(); - const off = within(await readLine()).getByTestId('studio-landing-customizations-switched-off'); - expect(off).toHaveAttribute('href', '/studio/com.example.showcase/metadata/action'); + const line = await readLine(); + expect(within(line).getByTestId('studio-landing-customizations-switched-off')).toHaveAttribute( + 'href', + '/studio/com.example.showcase/metadata/action', + ); + const named = within(line).getAllByTestId('studio-landing-customizations-switched-off-action'); + expect(named.map((a) => [a.textContent, a.getAttribute('href')])).toEqual([ + ['showcase_mark_done', '/studio/com.example.showcase/metadata/action/showcase_mark_done'], + ['showcase_portfolio_snapshot', '/studio/com.example.showcase/metadata/action/showcase_portfolio_snapshot'], + ]); + expect(within(line).getByTestId('studio-landing-customizations-switched-off-actions')).toHaveTextContent( + /^, Actions: showcase_mark_done, showcase_portfolio_snapshot$/, + ); + expect(within(line).queryByTestId('studio-landing-customizations-switched-off-actions-more')).not.toBeInTheDocument(); + fireEvent.click(named[1]); + await waitFor(() => + expect(screen.getByTestId('location')).toHaveTextContent( + '/studio/com.example.showcase/metadata/action/showcase_portfolio_snapshot', + ), + ); + }); + + it('more switched-off actions than the line names: the first three, then a "more" link to the list', async () => { + packages.list = [SHOWCASE]; + const names = ['a_one', 'a_two', 'a_three', 'a_four', 'a_five']; + stubWire({ 'com.example.showcase': servedOff('com.example.showcase', names.map((name) => ({ type: 'action', name }))) }); + renderLanding(); + const line = await readLine(); + expect( + within(line).getAllByTestId('studio-landing-customizations-switched-off-action').map((a) => a.textContent), + ).toEqual(['a_one', 'a_two', 'a_three']); + const more = within(line).getByTestId('studio-landing-customizations-switched-off-actions-more'); + expect(more).toHaveTextContent(tFormat('engine.studio.landing.customizations.switchedOffActionsMore', 'en-US', { count: 2 })); + expect(more).toHaveAttribute('href', '/studio/com.example.showcase/metadata/action'); }); - it('flows and actions switched off: the count opens Automations, and a second link the actions', async () => { + it('flows and actions switched off: the count opens Automations, and the line names the action', async () => { packages.list = [SHOWCASE]; stubWire({ 'com.example.showcase': servedOff('com.example.showcase', [ @@ -294,10 +326,11 @@ describe('Studio landing: "m switched off" leads to the switched-off actions (ob 'href', '/studio/com.example.showcase/automations', ); - const actions = within(line).getByTestId('studio-landing-customizations-switched-off-actions'); - expect(actions).toHaveTextContent(tFormat('engine.studio.landing.customizations.switchedOffActions', 'en-US', { count: 1 })); - expect(actions).toHaveAttribute('href', '/studio/com.example.showcase/metadata/action/showcase_mark_done'); - fireEvent.click(actions); + const [action] = within(line).getAllByTestId('studio-landing-customizations-switched-off-action'); + expect(action).toHaveTextContent('showcase_mark_done'); + expect(action).toHaveAttribute('title', t('engine.studio.landing.customizations.switchedOffActionsTitle', 'en-US')); + expect(action).toHaveAttribute('href', '/studio/com.example.showcase/metadata/action/showcase_mark_done'); + fireEvent.click(action); await waitFor(() => expect(screen.getByTestId('location')).toHaveTextContent('/studio/com.example.showcase/metadata/action/showcase_mark_done'), ); diff --git a/ui/packages/app-shell/src/views/studio-design/BuilderLanding.tsx b/ui/packages/app-shell/src/views/studio-design/BuilderLanding.tsx index ceab349d206..cfcf2bf016f 100644 --- a/ui/packages/app-shell/src/views/studio-design/BuilderLanding.tsx +++ b/ui/packages/app-shell/src/views/studio-design/BuilderLanding.tsx @@ -74,6 +74,9 @@ const studioPillarPath = (packageId: string, pillar: 'data' | 'automations') => * action in Studio. One action opens its own page in the "All metadata" area, * where the switch reads off; more than one opens that area's action list. */ +/** How many switched-off actions the landing line names before its "more" link (objectstack#34724). */ +const SWITCHED_OFF_ACTIONS_NAMED = 3; + const switchedOffActionsPath = (packageId: string, actions: readonly string[]) => { const list = `/studio/${encodeURIComponent(packageId)}/metadata/action`; return actions.length === 1 ? `${list}/${encodeURIComponent(actions[0])}` : list; @@ -267,11 +270,17 @@ export function BuilderLanding(): React.ReactElement { const linkClass = 'hover:text-foreground hover:underline'; // objectstack#34724 — the "switched off" count leads to the items: a flow's // switch is in the Automations pillar, an action's on the action. When - // every switched-off item is an action, the count opens them; when flows - // are among them too, the count opens Automations and a second link the - // actions. + // every switched-off item is an action, the count opens it (one) or the + // action list (several); when flows are among them, the count opens + // Automations. Whenever the count alone does not land on the action, the + // line names each switched-off action as a link to its own page (the + // action list marks none of them), up to SWITCHED_OFF_ACTIONS_NAMED, then + // a "more" link to the list. const offActions = line.counts.switchedOffActions ?? []; const offOnlyActions = offActions.length > 0 && offActions.length === line.counts.switchedOff; + const nameActions = offActions.length > 1 || (offActions.length > 0 && !offOnlyActions); + const namedActions = offActions.slice(0, SWITCHED_OFF_ACTIONS_NAMED); + const moreActions = offActions.length - namedActions.length; return (

{pair ? ( @@ -302,18 +311,36 @@ export function BuilderLanding(): React.ReactElement { switchedOff: line.counts.switchedOff, })} - {offActions.length > 0 && !offOnlyActions && ( - <> - {' '} - - {tFormat('engine.studio.landing.customizations.switchedOffActions', locale, { count: offActions.length })} - - + {nameActions && ( + + {t('engine.studio.landing.customizations.separator', locale)} + {t('engine.studio.landing.customizations.switchedOffActionsLead', locale)} + {namedActions.map((name, i) => ( + + {i > 0 && t('engine.studio.landing.customizations.separator', locale)} + + {name} + + + ))} + {moreActions > 0 && ( + <> + {' '} + + {tFormat('engine.studio.landing.customizations.switchedOffActionsMore', locale, { count: moreActions })} + + + )} + )}

); diff --git a/ui/packages/i18n/src/namespaces/studio/en.ts b/ui/packages/i18n/src/namespaces/studio/en.ts index 128a7c324ca..f025780e6a2 100644 --- a/ui/packages/i18n/src/namespaces/studio/en.ts +++ b/ui/packages/i18n/src/namespaces/studio/en.ts @@ -3427,7 +3427,8 @@ const STUDIO_EN: Record = { 'engine.studio.landing.customizations.failed': 'Couldn’t read customizations', 'engine.studio.landing.customizations.pairTitle': 'Open the customization package {pair} in Studio', 'engine.studio.landing.customizations.switchedOffTitle': 'Open this package’s Automations, where its items are switched on and off', - 'engine.studio.landing.customizations.switchedOffActions': '(actions: {count})', + 'engine.studio.landing.customizations.switchedOffActionsLead': 'Actions: ', + 'engine.studio.landing.customizations.switchedOffActionsMore': '+{count} more', 'engine.studio.landing.customizations.switchedOffActionsTitle': 'Open the switched-off actions: each one is switched on again on the action', // objectui#11553 — the package-less scope: the organization's own flows. 'engine.studio.landing.orgHeading': 'Not in a package', diff --git a/ui/packages/i18n/src/namespaces/studio/zh.ts b/ui/packages/i18n/src/namespaces/studio/zh.ts index 902effbf2e9..130466c951e 100644 --- a/ui/packages/i18n/src/namespaces/studio/zh.ts +++ b/ui/packages/i18n/src/namespaces/studio/zh.ts @@ -3023,7 +3023,8 @@ const STUDIO_ZH: Record = { 'engine.studio.landing.customizations.failed': '无法读取定制', 'engine.studio.landing.customizations.pairTitle': '在 Studio 中打开定制包 {pair}', 'engine.studio.landing.customizations.switchedOffTitle': '打开该软件包的自动化,在那里启用或停用其中的项', - 'engine.studio.landing.customizations.switchedOffActions': '(其中动作 {count} 项)', + 'engine.studio.landing.customizations.switchedOffActionsLead': '动作:', + 'engine.studio.landing.customizations.switchedOffActionsMore': '另 {count} 项', 'engine.studio.landing.customizations.switchedOffActionsTitle': '打开已停用的动作:在动作上即可重新启用', // objectui#11553 — the package-less scope: the organization's own flows. 'engine.studio.landing.orgHeading': '不属于软件包', From d94e711ea02406ef9037e378cbb42a6ad74924bb Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 17 Nov 2026 12:58:22 +0000 Subject: [PATCH 07/12] refactor(studio): the landing's switched-off actions path keeps its own doc comment Co-Authored-By: Claude Claude-Session: https://claude.ai/code/session_01WGufziD6XhBNH9acXaG2Me --- .../app-shell/src/views/studio-design/BuilderLanding.tsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ui/packages/app-shell/src/views/studio-design/BuilderLanding.tsx b/ui/packages/app-shell/src/views/studio-design/BuilderLanding.tsx index cfcf2bf016f..901681f543b 100644 --- a/ui/packages/app-shell/src/views/studio-design/BuilderLanding.tsx +++ b/ui/packages/app-shell/src/views/studio-design/BuilderLanding.tsx @@ -68,15 +68,15 @@ type CustomizationLine = const studioPillarPath = (packageId: string, pillar: 'data' | 'automations') => `/studio/${encodeURIComponent(packageId)}/${pillar}`; +/** How many switched-off actions the landing line names before its "more" link (objectstack#34724). */ +const SWITCHED_OFF_ACTIONS_NAMED = 3; + /** * objectstack#34724 (ADR-0146 D4 as amended 2026-11-17) — where a base's * switched-off actions are switched on again: an action's switch is on the * action in Studio. One action opens its own page in the "All metadata" area, * where the switch reads off; more than one opens that area's action list. */ -/** How many switched-off actions the landing line names before its "more" link (objectstack#34724). */ -const SWITCHED_OFF_ACTIONS_NAMED = 3; - const switchedOffActionsPath = (packageId: string, actions: readonly string[]) => { const list = `/studio/${encodeURIComponent(packageId)}/metadata/action`; return actions.length === 1 ? `${list}/${encodeURIComponent(actions[0])}` : list; From 26ad7aa0068e6ff9c000a5597fdff35fcf39fe6d Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 17 Nov 2026 13:23:54 +0000 Subject: [PATCH 08/12] feat(studio): a switched-off action its object holds links to that object's Actions view An action declared inside its object has no item page, so the landing's link to it answered not found. The landing reads which of the app's objects holds each switched-off action and links it to the Data pillar's Actions view with the action selected, through a new ?action= beside ?surface=object:; an action no object holds keeps its item page. Co-Authored-By: Claude Claude-Session: https://claude.ai/code/session_01WGufziD6XhBNH9acXaG2Me --- .../34724-action-switch-moves-to-studio.md | 2 +- ...Landing.customizationCounts-28566.test.tsx | 76 +++++++- .../views/studio-design/BuilderLanding.tsx | 86 +++++--- .../DataPillar.actionDeepLink-34724.test.tsx | 183 ++++++++++++++++++ .../studio-design/StudioDesignSurface.tsx | 5 + .../studio-design/switchedOffActionTargets.ts | 72 +++++++ .../views/studio-design/useSurfaceDeepLink.ts | 34 ++++ 7 files changed, 422 insertions(+), 36 deletions(-) create mode 100644 ui/packages/app-shell/src/views/studio-design/DataPillar.actionDeepLink-34724.test.tsx create mode 100644 ui/packages/app-shell/src/views/studio-design/switchedOffActionTargets.ts diff --git a/.changeset/34724-action-switch-moves-to-studio.md b/.changeset/34724-action-switch-moves-to-studio.md index 38e7a9a479f..764402dc7e9 100644 --- a/.changeset/34724-action-switch-moves-to-studio.md +++ b/.changeset/34724-action-switch-moves-to-studio.md @@ -21,7 +21,7 @@ Before this change, the deployment's on/off switch for an installed app's action - On the object's Actions view in Studio, a read-only app package's vendor action carries a "Switched on / off for this deployment" switch, the flow switch's twin. A switched-off action is marked in the list. A refusal is the server's sentence, shown verbatim; a caller the deployment's posture walls off sees the switch disabled with the reason. - A standalone `action` item's page in Studio's "All metadata" area carries the same switch. - The platform's own actions (any action a kernel package ships) carry no switch anywhere. When the package list cannot be read, no switch is offered. -- Studio's landing leads to them: an app's "N switched off" count opens the switched-off action itself (one) or the action list (several), and when that does not land on an action (several, or flows among them), the line names each switched-off action as a link to its page, three at most, then a "more" link to the list. +- Studio's landing leads to them: an app's "N switched off" count opens the switched-off action (one) or the action list (several), and when that does not land on an action (several, or flows among them), the line names each switched-off action as a link, three at most, then a "more" link to the list. An action its object holds opens on that object's Actions view (a new `?action=` beside `?surface=object:` in the Data pillar selects it), since an action declared inside its object has no page of its own; any other action opens its own page. The doors are unchanged: the read is the `sys_metadata_activation` ledger, the write is `POST /api/v1/actions/_activation/:object/:action` with body `{ enabled }`. diff --git a/ui/packages/app-shell/src/views/studio-design/BuilderLanding.customizationCounts-28566.test.tsx b/ui/packages/app-shell/src/views/studio-design/BuilderLanding.customizationCounts-28566.test.tsx index 6631e4e77f8..4ad4dff24bc 100644 --- a/ui/packages/app-shell/src/views/studio-design/BuilderLanding.customizationCounts-28566.test.tsx +++ b/ui/packages/app-shell/src/views/studio-design/BuilderLanding.customizationCounts-28566.test.tsx @@ -57,15 +57,27 @@ function served(id: string, overrides: number, extensions: number, switchedOff: type Answer = { status: number; body: unknown } | 'never'; +const OBJECT_LIST_RE = /\/meta\/object\?package=([^&]+)/; + /** * Stub the wire: each customization request is answered from `answers` by - * base id; every request URL is recorded. + * base id, and each object list (`/meta/object?package=`) from `objects` by + * package id when it names one; every request URL is recorded. */ -function stubWire(answers: Record) { +function stubWire(answers: Record, objects: Record = {}) { const requested: string[] = []; const fetchMock = vi.fn(async (input: RequestInfo | URL) => { const url = String(input); requested.push(url); + const o = OBJECT_LIST_RE.exec(url); + const listed = o ? objects[decodeURIComponent(o[1])] : undefined; + if (listed) { + // A real Response: the metadata client reads its headers. + return new Response(JSON.stringify(listed), { + status: 200, + headers: { 'content-type': 'application/json' }, + }); + } const m = CUSTOMIZATIONS_RE.exec(url); const answer = m ? answers[decodeURIComponent(m[1])] : undefined; if (answer === 'never') return new Promise(() => {}); @@ -84,8 +96,13 @@ function stubWire(answers: Record) { const customizationRequests = (requested: string[]) => requested.filter((u) => CUSTOMIZATIONS_RE.test(u)); function LocationProbe() { - const { pathname } = useLocation(); - return
{pathname}
; + const { pathname, search } = useLocation(); + return ( + <> +
{pathname}
+
{search}
+ + ); } function renderLanding() { @@ -336,6 +353,57 @@ describe('Studio landing: "m switched off" leads to the switched-off actions (ob ); }); + // L2 M1 — an action declared inside its object has no item page: its switch + // is on the object's Actions view, which the link opens on it. + const TASK_OBJECT = { + name: 'showcase_task', + label: 'Task', + actions: [{ name: 'showcase_embedded_probe' }, { name: 'showcase_mark_done', objectName: 'showcase_task' }], + }; + const embeddedPath = '/studio/com.example.showcase/data?surface=object%3Ashowcase_task&action=showcase_embedded_probe'; + + it('one switched-off action its object holds: the count opens the object\'s Actions view on it', async () => { + packages.list = [SHOWCASE]; + const { requested } = stubWire( + { 'com.example.showcase': servedOff('com.example.showcase', [{ type: 'action', name: 'showcase_embedded_probe' }]) }, + { 'com.example.showcase': [TASK_OBJECT, { name: 'showcase_invoice', label: 'Invoice' }] }, + ); + renderLanding(); + const off = within(await readLine()).getByTestId('studio-landing-customizations-switched-off'); + expect(off).toHaveAttribute('href', embeddedPath); + expect(requested.some((u) => OBJECT_LIST_RE.test(u))).toBe(true); + fireEvent.click(off); + await waitFor(() => expect(screen.getByTestId('location')).toHaveTextContent('/studio/com.example.showcase/data')); + expect(screen.getByTestId('location-search')).toHaveTextContent('?surface=object%3Ashowcase_task&action=showcase_embedded_probe'); + }); + + it('several: each named action links where it is switched, its object\'s Actions view or its own page', async () => { + packages.list = [SHOWCASE]; + stubWire( + { + 'com.example.showcase': servedOff('com.example.showcase', [ + { type: 'action', name: 'showcase_embedded_probe' }, + { type: 'action', name: 'showcase_portfolio_snapshot' }, + ]), + }, + { 'com.example.showcase': [TASK_OBJECT] }, + ); + renderLanding(); + const named = within(await readLine()).getAllByTestId('studio-landing-customizations-switched-off-action'); + expect(named.map((a) => [a.textContent, a.getAttribute('href')])).toEqual([ + ['showcase_embedded_probe', embeddedPath], + ['showcase_portfolio_snapshot', '/studio/com.example.showcase/metadata/action/showcase_portfolio_snapshot'], + ]); + }); + + it('no object list read when nothing switched off is an action', async () => { + packages.list = [SHOWCASE]; + const { requested } = stubWire({ 'com.example.showcase': servedOff('com.example.showcase', [{ type: 'flow', name: 'showcase_nightly' }]) }); + renderLanding(); + await readLine(); + expect(requested.some((u) => OBJECT_LIST_RE.test(u))).toBe(false); + }); + it('flows only: the count opens Automations, with no actions link (unchanged)', async () => { packages.list = [SHOWCASE]; stubWire({ 'com.example.showcase': servedOff('com.example.showcase', [{ type: 'flow', name: 'showcase_nightly' }]) }); diff --git a/ui/packages/app-shell/src/views/studio-design/BuilderLanding.tsx b/ui/packages/app-shell/src/views/studio-design/BuilderLanding.tsx index 901681f543b..465fae7a747 100644 --- a/ui/packages/app-shell/src/views/studio-design/BuilderLanding.tsx +++ b/ui/packages/app-shell/src/views/studio-design/BuilderLanding.tsx @@ -35,6 +35,12 @@ import { PackageFormDialog } from '../metadata-admin/PackageFormDialog.js'; import { isMarketplaceEnabled } from '../../runtime-config.js'; import { fetchPackages, fetchListedPackageIds, duplicatePackage, isSpecPackageId, type PkgEntry } from './packages-io.js'; import { fetchPackageCustomizationCounts, type PackageCustomizationCounts } from './packageCustomizations-io.js'; +import { + readActionObjects, + switchedOffActionListPath, + switchedOffActionPath, + type ActionObjects, +} from './switchedOffActionTargets.js'; import { customizationPackageId, isCustomizationPackage } from '@objectstack/spec/kernel'; import { PackageIdInput } from './PackageIdInput.js'; import { studioOrgScopePath } from './studioScope.js'; @@ -61,7 +67,16 @@ const RECENT_PACKAGES_SHOWN = 3; * read. No entry means the read has not answered: the line shows no number. */ type CustomizationLine = - | { kind: 'read'; counts: PackageCustomizationCounts } + | { + kind: 'read'; + counts: PackageCustomizationCounts; + /** + * objectstack#34724 — which object holds each switched-off action, read + * only when the base has one (`readActionObjects`); empty when that read + * failed, so every action then links to its item page. + */ + actionObjects?: ActionObjects; + } | { kind: 'failed'; message: string }; /** A package's Studio address on one pillar, the way `open` below spells it. */ @@ -71,16 +86,6 @@ const studioPillarPath = (packageId: string, pillar: 'data' | 'automations') => /** How many switched-off actions the landing line names before its "more" link (objectstack#34724). */ const SWITCHED_OFF_ACTIONS_NAMED = 3; -/** - * objectstack#34724 (ADR-0146 D4 as amended 2026-11-17) — where a base's - * switched-off actions are switched on again: an action's switch is on the - * action in Studio. One action opens its own page in the "All metadata" area, - * where the switch reads off; more than one opens that area's action list. - */ -const switchedOffActionsPath = (packageId: string, actions: readonly string[]) => { - const list = `/studio/${encodeURIComponent(packageId)}/metadata/action`; - return actions.length === 1 ? `${list}/${encodeURIComponent(actions[0])}` : list; -}; export function BuilderLanding(): React.ReactElement { const navigate = useNavigate(); @@ -180,30 +185,41 @@ export function BuilderLanding(): React.ReactElement { .map((p) => p.id) .join('\n'); const [customizationLines, setCustomizationLines] = React.useState>({}); + const metadataClient = useMetadataClient(); React.useEffect(() => { if (!customizationTargetKey) return; let cancelled = false; for (const id of customizationTargetKey.split('\n')) { - fetchPackageCustomizationCounts(id).then( - (counts) => { - if (!cancelled) setCustomizationLines((prev) => ({ ...prev, [id]: { kind: 'read', counts } })); - }, - (e: unknown) => { - const message = e instanceof Error ? e.message : String(e); - if (!cancelled) setCustomizationLines((prev) => ({ ...prev, [id]: { kind: 'failed', message } })); - }, - ); + fetchPackageCustomizationCounts(id) + .then(async (counts) => { + // objectstack#34724 — a switched-off action's link needs its object, + // which the ledger row does not name: read it before drawing the line. + if (!counts.switchedOffActions?.length) return { counts }; + const actionObjects = await readActionObjects(metadataClient, id).catch((): ActionObjects => ({})); + return { counts, actionObjects }; + }) + .then( + (line) => { + if (!cancelled) setCustomizationLines((prev) => ({ ...prev, [id]: { kind: 'read', ...line } })); + }, + (e: unknown) => { + const message = e instanceof Error ? e.message : String(e); + if (!cancelled) setCustomizationLines((prev) => ({ ...prev, [id]: { kind: 'failed', message } })); + }, + ); } return () => { cancelled = true; }; + // Keyed on the ids alone: the client only carries the reads, and a new + // client identity must not read every card again. + // eslint-disable-next-line react-hooks/exhaustive-deps }, [customizationTargetKey]); // objectui#11553 — how many flows belong to no package: the same published // and draft union the package-less scope lists (`loadPackageLessSurfaces`). // The entry is drawn once the read says there is at least one; a failed read // draws it with no number, so the scope stays reachable when the count is // unknown. `null` = not answered yet. - const metadataClient = useMetadataClient(); const [packageLessFlows, setPackageLessFlows] = React.useState(null); React.useEffect(() => { let cancelled = false; @@ -269,14 +285,16 @@ export function BuilderLanding(): React.ReactElement { }); const linkClass = 'hover:text-foreground hover:underline'; // objectstack#34724 — the "switched off" count leads to the items: a flow's - // switch is in the Automations pillar, an action's on the action. When - // every switched-off item is an action, the count opens it (one) or the - // action list (several); when flows are among them, the count opens - // Automations. Whenever the count alone does not land on the action, the - // line names each switched-off action as a link to its own page (the - // action list marks none of them), up to SWITCHED_OFF_ACTIONS_NAMED, then - // a "more" link to the list. + // switch is in the Automations pillar, an action's where the action is + // drawn (`switchedOffActionPath`: its object's Actions view, or its own + // item page when no object holds it). When every switched-off item is an + // action, the count opens it (one) or the action list (several); when + // flows are among them, the count opens Automations. Whenever the count + // alone does not land on the action, the line names each switched-off + // action as a link to where it is switched (the action list marks none of + // them), up to SWITCHED_OFF_ACTIONS_NAMED, then a "more" link to the list. const offActions = line.counts.switchedOffActions ?? []; + const actionPath = (name: string) => switchedOffActionPath(baseId, name, line.actionObjects?.[name]); const offOnlyActions = offActions.length > 0 && offActions.length === line.counts.switchedOff; const nameActions = offActions.length > 1 || (offActions.length > 0 && !offOnlyActions); const namedActions = offActions.slice(0, SWITCHED_OFF_ACTIONS_NAMED); @@ -297,7 +315,13 @@ export function BuilderLanding(): React.ReactElement { )} {t('engine.studio.landing.customizations.separator', locale)} {i > 0 && t('engine.studio.landing.customizations.separator', locale)} {' '} diff --git a/ui/packages/app-shell/src/views/studio-design/DataPillar.actionDeepLink-34724.test.tsx b/ui/packages/app-shell/src/views/studio-design/DataPillar.actionDeepLink-34724.test.tsx new file mode 100644 index 00000000000..51e9f18c91e --- /dev/null +++ b/ui/packages/app-shell/src/views/studio-design/DataPillar.actionDeepLink-34724.test.tsx @@ -0,0 +1,183 @@ +// Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license. + +/** + * objectstack#34724 (ADR-0146 D4 as amended 2026-11-17) — a Data pillar link + * can open an object's Actions view on one action: + * `?surface=object:&action=`. Studio's landing links a + * switched-off action that lives in its object's `actions[]` here, since such + * an action has no item page and its switch is on the Actions view. + * + * On the real pillar with the real action inspector: + * - the link opens the object on the Actions view, the named action selected + * (its inspector shows its label, not the first action's); + * - CONTROL: the same link without `action=` opens the object on Records, as + * before, with no action inspector; + * - the param is read once: picking another view afterwards stays there. + */ + +import '@testing-library/jest-dom/vitest'; +import * as React from 'react'; +import { afterEach, describe, expect, it, vi } from 'vitest'; +import { render, screen, fireEvent, cleanup, act } from '@testing-library/react'; +import { MemoryRouter } from 'react-router-dom'; +import { MetadataClient } from '@object-ui/data-objectstack'; +import { ActionSchema } from '@objectstack/spec/ui'; + +const SEND = { + name: 'showcase_task_send', + label: 'Send', + objectName: 'showcase_task', + locations: ['record_more'], + type: 'script', + body: { language: 'expression', source: 'true' }, +}; +const ARCHIVE = { ...SEND, name: 'showcase_task_archive', label: 'Archive' }; + +let objectDef: Record = {}; + +/** Every PUT the transport received, parsed. */ +const puts: Array> = []; + +/** The server's answer to a PUT: each action parsed with the spec. */ +function serverIssues(body: Record): Array<{ path: string; message: string; code: string }> { + const actions = Array.isArray(body.actions) ? body.actions : []; + return actions.flatMap((action, index) => { + const parsed = ActionSchema.safeParse(action); + return parsed.success + ? [] + : parsed.error.issues.map((issue) => ({ + path: ['actions', index, ...issue.path].join('.'), + message: issue.message, + code: issue.code, + })); + }); +} + +const fetchImpl = vi.fn(async (_url: string, init?: RequestInit) => { + if (init?.method === 'PUT') { + const body = JSON.parse(String(init.body)) as Record; + puts.push(body); + const issues = serverIssues(body); + if (issues.length > 0) { + return new Response( + JSON.stringify({ + success: false, + error: { + message: '[invalid_metadata] object/showcase_task failed spec validation', + code: 422, + details: { code: 'invalid_metadata', issues }, + }, + }), + { status: 422, headers: { 'content-type': 'application/json' } }, + ); + } + return new Response(JSON.stringify({ success: true }), { status: 200, headers: { 'content-type': 'application/json' } }); + } + return new Response('null', { status: 404, headers: { 'content-type': 'application/json' } }); +}); + +const client = new MetadataClient({ baseUrl: 'http://test.local', fetch: fetchImpl as unknown as typeof fetch }); +Object.assign(client, { + list: vi.fn(async () => [{ name: 'showcase_task', label: 'Task' }]), + listDrafts: vi.fn(async () => []), + layered: vi.fn(async () => ({ effective: objectDef, code: objectDef })), + getDraft: vi.fn(async () => null), +}); + +vi.mock('../metadata-admin/useMetadata', async (importOriginal) => { + const mod = await importOriginal(); + return { ...mod, useMetadataClient: () => client, useMetadataTypes: () => ({ entries: [] }) }; +}); + +vi.mock('./packages-io', async (importOriginal) => { + const mod = await importOriginal(); + return { ...mod, fetchPackages: vi.fn(async () => []) }; +}); + +// The Advanced views live in a Radix DropdownMenu; rendered as passthroughs, +// as in DataPillar.inspectorBelongsToView-11781.test.tsx. +type PassthroughProps = { children?: React.ReactNode; onSelect?: () => void }; +vi.mock('@object-ui/components', async (importOriginal) => { + const mod = await importOriginal(); + return { + ...mod, + DropdownMenu: (p: PassthroughProps) =>
{p.children}
, + DropdownMenuTrigger: (p: PassthroughProps) =>
{p.children}
, + DropdownMenuContent: (p: PassthroughProps) =>
{p.children}
, + DropdownMenuItem: (p: PassthroughProps) => ( + + ), + DropdownMenuRadioGroup: (p: PassthroughProps) =>
{p.children}
, + DropdownMenuRadioItem: (p: PassthroughProps) => ( + + ), + }; +}); + +vi.mock('@object-ui/react', async (importOriginal) => { + const mod = await importOriginal(); + return { ...mod, useAdapter: () => dataSource }; +}); + +import { DataPillar } from './StudioDesignSurface'; +import { createEmptyDataSource } from './__tests__/emptyDataSource'; +import { registerBuiltinInspectors } from '../metadata-admin/inspectors'; +import { t } from '../metadata-admin/i18n'; + +const dataSource = createEmptyDataSource(); +registerBuiltinInspectors(); + +afterEach(() => { + cleanup(); + puts.length = 0; + fetchImpl.mockClear(); +}); + +const L = (key: string) => t(key, 'en'); + +const TASK = { + name: 'showcase_task', + label: 'Task', + fields: [{ name: 'title', label: 'Title', type: 'text' }], + actions: [ARCHIVE, SEND], +}; + +function mountAt(search: string): void { + objectDef = TASK; + render( + + + , + ); +} + +const labelInput = async () => + (await screen.findByText(L('engine.inspector.action.label'), { selector: 'label' })).parentElement!.querySelector('input')!; + +describe('Studio data page — `?action=` opens the object\'s Actions view on that action (objectstack#34724)', () => { + it('lands on the Actions view with the named action selected, not the first one', async () => { + mountAt('?surface=object%3Ashowcase_task&action=showcase_task_send'); + expect(await labelInput()).toHaveValue('Send'); + expect(screen.queryByDisplayValue('Archive')).not.toBeInTheDocument(); + }); + + it('CONTROL: without `action=` the object opens on Records, with no action inspector', async () => { + mountAt('?surface=object%3Ashowcase_task'); + // The object loaded: its tabs are drawn. + await screen.findAllByRole('button', { name: L('engine.studio.data.tab.actions') }); + await act(async () => { + await new Promise((r) => setTimeout(r, 200)); + }); + expect(screen.queryByText(L('engine.inspector.action.label'), { selector: 'label' })).not.toBeInTheDocument(); + }); + + it('is read once: a later pick of another view stays there', async () => { + mountAt('?surface=object%3Ashowcase_task&action=showcase_task_send'); + expect(await labelInput()).toHaveValue('Send'); + fireEvent.click(screen.getAllByRole('button', { name: L('engine.studio.data.tab.form') })[0]); + await act(async () => { + await new Promise((r) => setTimeout(r, 200)); + }); + expect(screen.queryByText(L('engine.inspector.action.label'), { selector: 'label' })).not.toBeInTheDocument(); + }); +}); diff --git a/ui/packages/app-shell/src/views/studio-design/StudioDesignSurface.tsx b/ui/packages/app-shell/src/views/studio-design/StudioDesignSurface.tsx index 1bd3f838f99..607b465c828 100644 --- a/ui/packages/app-shell/src/views/studio-design/StudioDesignSurface.tsx +++ b/ui/packages/app-shell/src/views/studio-design/StudioDesignSurface.tsx @@ -348,6 +348,7 @@ import { useSurfaceDeepLink, useSurfaceDeepLinkCapture, useSurfaceDeepLinkMirror, + useSurfaceActionDeepLink, resolveSurfaceDeepLink, type SurfaceTarget, } from './useSurfaceDeepLink.js'; @@ -5650,6 +5651,10 @@ export function DataPillar({ } setFieldSel({ kind: target.kind, id: target.id }); }; + // objectstack#34724 — `?surface=object:&action=` opens the + // deep-linked object's Actions view on that action (Studio's landing links a + // switched-off action that lives in its object's `actions[]` here). + useSurfaceActionDeepLink(initialSurface, current, (name) => showObjTarget({ kind: 'action', id: name })); // objectstack#26730 — a refusal's "Show me" also ends on the input it names: // in the field inspector, or in the actions panel for an action. const fieldInspectorBodyRef = React.useRef(null); diff --git a/ui/packages/app-shell/src/views/studio-design/switchedOffActionTargets.ts b/ui/packages/app-shell/src/views/studio-design/switchedOffActionTargets.ts new file mode 100644 index 00000000000..77a5da2c4fa --- /dev/null +++ b/ui/packages/app-shell/src/views/studio-design/switchedOffActionTargets.ts @@ -0,0 +1,72 @@ +// Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license. + +/** + * objectstack#34724 (ADR-0146 D4 as amended 2026-11-17) — where Studio's + * landing sends a switched-off action of an installed app: to the place its + * switch is drawn. + * + * - An action an object holds (its served `actions[]`, which carries the + * actions declared inside the object and the top-level ones bound to it by + * `objectName`) is switched on the object's Actions view in the Data + * pillar: `?surface=object:&action=` opens that view on it. + * An action declared inside its object has no item of its own, so this is + * the only page that shows it. + * - Any other action (one bound to no object) is a standalone `action` item: + * its page in the "All metadata" area carries the switch. + * + * The ledger row the customization read serves names the action only, never + * its object, so the object is read here: one `list('object', { packageId })` + * of the app, the same read the Data pillar lists its objects with. + */ + +import { DESIGNER_SURFACE_PARAM, formatSurfaceParam } from '../metadata-admin/nav-selection.js'; +import { DESIGNER_SURFACE_ACTION_PARAM } from './useSurfaceDeepLink.js'; + +/** The slice of the metadata client the object read uses. */ +export interface ActionObjectClient { + list(type: string, options?: { packageId?: string }): Promise; +} + +/** Action name → the object whose served `actions[]` holds it. */ +export type ActionObjects = Readonly>; + +/** + * Read which of `packageId`'s objects holds each action, off the app's served + * objects. Rejects when the list fails; an object or action without a name is + * skipped, and the first object that holds a name keeps it. + */ +export async function readActionObjects(client: ActionObjectClient, packageId: string): Promise { + const objects = await client.list('object', { packageId }); + const out: Record = {}; + if (!Array.isArray(objects)) return out; + for (const raw of objects) { + if (!raw || typeof raw !== 'object') continue; + const object = raw as { name?: unknown; actions?: unknown }; + if (typeof object.name !== 'string' || !object.name || !Array.isArray(object.actions)) continue; + for (const action of object.actions) { + const name = action && typeof action === 'object' ? (action as { name?: unknown }).name : undefined; + if (typeof name === 'string' && name && !(name in out)) out[name] = object.name; + } + } + return out; +} + +/** + * The page a switched-off action is switched on again from: its object's + * Actions view when `object` names one, else the action's own item page. + */ +export function switchedOffActionPath(packageId: string, name: string, object: string | null | undefined): string { + const pkg = encodeURIComponent(packageId); + if (object) { + const query = new URLSearchParams({ + [DESIGNER_SURFACE_PARAM]: formatSurfaceParam({ type: 'object', name: object }), + [DESIGNER_SURFACE_ACTION_PARAM]: name, + }); + return `/studio/${pkg}/data?${query.toString()}`; + } + return `/studio/${pkg}/metadata/action/${encodeURIComponent(name)}`; +} + +/** The app's action list in the "All metadata" area: where several switched-off actions are listed. */ +export const switchedOffActionListPath = (packageId: string): string => + `/studio/${encodeURIComponent(packageId)}/metadata/action`; diff --git a/ui/packages/app-shell/src/views/studio-design/useSurfaceDeepLink.ts b/ui/packages/app-shell/src/views/studio-design/useSurfaceDeepLink.ts index 8e3722080c9..a990600b168 100644 --- a/ui/packages/app-shell/src/views/studio-design/useSurfaceDeepLink.ts +++ b/ui/packages/app-shell/src/views/studio-design/useSurfaceDeepLink.ts @@ -70,6 +70,16 @@ export const DESIGNER_SURFACE_NAV_PARAM = 'nav'; */ export const DESIGNER_SURFACE_VIEW_PARAM = 'view'; +/** + * objectstack#34724 — the action a Data pillar link opens on its object: + * `?surface=object:&action=` lands on the object's Actions view + * with that action selected. Studio's landing links a switched-off action + * that lives in its object's `actions[]` here, since such an action has no + * item page of its own and its switch is on the object's Actions view. A key + * of its own, for the reason `nav` is one. + */ +export const DESIGNER_SURFACE_ACTION_PARAM = 'action'; + /** * The surface identity carried in the URL: `?surface=` plus, on an Interfaces * nav entry, its id from `?nav=` and the list view it shows from `?view=` @@ -173,3 +183,27 @@ export function resolveSurfaceDeepLink( if (!initial || initial.type !== expectedType) return undefined; return items.find((item) => item.name === initial.name); } + +/** + * objectstack#34724 — the mount-time `?action=` beside a `?surface=object:` + * deep link: once the deep-linked object is the open one, `open(name)` runs, + * once (the pillar's own "Show me" path to an action). Read once at mount like + * the surface itself, so the author's later picks are never overridden. + */ +export function useSurfaceActionDeepLink( + initial: SurfaceTarget | null, + current: SurfaceTarget | null | undefined, + open: (name: string) => void, +): void { + const [searchParams] = useSearchParams(); + const pendingRef = React.useRef(searchParams.get(DESIGNER_SURFACE_ACTION_PARAM) || null); + const currentName = current?.type === 'object' ? current.name : null; + // `open` is a new function per render; the pending name, spent on first + // use, keeps it to one call. + React.useEffect(() => { + const name = pendingRef.current; + if (!name || initial?.type !== 'object' || currentName !== initial.name) return; + pendingRef.current = null; + open(name); + }, [initial, currentName, open]); +} From a9aed707e36982a99c601dd3736de52abbc699ae Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 17 Nov 2026 14:03:49 +0000 Subject: [PATCH 09/12] docs(reference): regenerate the protocol reference after merging main Co-Authored-By: Claude Claude-Session: https://claude.ai/code/session_01WGufziD6XhBNH9acXaG2Me --- content/docs/references/api/protocol.mdx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/content/docs/references/api/protocol.mdx b/content/docs/references/api/protocol.mdx index 6cd9e3e3c87..65efa76f311 100644 --- a/content/docs/references/api/protocol.mdx +++ b/content/docs/references/api/protocol.mdx @@ -1711,7 +1711,7 @@ One changed key path of the pending draft, and the last write that changed it. | :--- | :--- | :--- | :--- | | **object** | `string` | ✅ | Object name | | **permissions** | `{ allowCreate?: boolean; allowRead?: boolean; allowEdit?: boolean; allowDelete?: boolean; … }` | ✅ | Object-level permissions | -| **fieldPermissions** | `Record` | optional | Field-level permissions keyed by field name | +| **fieldPermissions** | `Record` | optional | Field-level permissions keyed by field name | ### Nested Shape: `GetObjectPermissionsResponse.permissions` @@ -1739,6 +1739,7 @@ One changed key path of the pending draft, and the last write that changed it. | **readable** | `boolean` | optional (default: `true`) | Field read access | | **editable** | `boolean` | optional (default: `false`) | Field edit access | | **when** | `string` | optional | Row condition narrowing where this entry votes, authored in canonical CEL like `rowLevelSecurity[].using` (a field of this object compared with a literal or a `current_user.*` value using `==`, `!=`, `<`, `<=`, `>`, `>=` or `in`, combined with `&&` / `\|\|`; e.g. status in ["approved", "signing", "active"]). Absent, the entry votes on every row. Present, the entry votes as declared on the rows the condition matches and is ABSENT on every other row, so the most-permissive merge across the caller's sets is unchanged: a set that locks a field only from a stage onward does not lock the rows before it, and a co-held set that says nothing about the field still lifts nothing, unless it holds the super-user bypass on the object (its own entry for the object, otherwise its `'*'` wildcard). Such a set votes on every field of the object, on every row, whatever `when` says: `viewAllRecords` votes `readable: true`, and `modifyAllRecords` votes `readable: true` and `editable: true`, so a row-conditioned lock never binds a Modify All holder. View All never grants an edit. Otherwise union without deny is unchanged. The write gate judges the condition on the stored row BEFORE an update (so a lock on `status in [...]` holds on an approved row even when the write changes `status`) and on the incoming row of an insert, as the caller sent it. It reaches the EDIT vote only — reads are judged row-blind — so `readable: false` beside a `when` is refused at parse time: keep `readable: true` (the default) on a row-conditioned entry. Where no row can be judged (a predicate update with no row address, a stored row the caller cannot read, a condition that does not resolve for the request) the entry is judged as its lock: it contributes no edit grant on that write. Validated like an RLS predicate at authoring and publish time: the fields it names must exist on the entry's object and it may not reach across a relation; a condition that cannot be lowered is refused there, never dropped at runtime. Readers that hold no row (`/auth/me/permissions`, the object-wide field projections, the write preview on an update) report a row-conditioned entry as its lock, so a client never advertises an edit the gate refuses. The record-scoped field projection (`GET /data/{object}/{id}/field-access`, the answer a record's edit form reads) holds the row: it judges the condition on the stored row exactly as the write gate does on an update of that row, so a lock that applies only from a stage onward disables the field only on the rows it names. | +| **rollupSourceUnreadableReason** | `string` | optional | Authoring-time acknowledgement, read only by `os lint` (the runtime does not read it): why holders of this set are meant to read this roll-up `summary` column although the set cannot read the child object, the aggregated child field or a child field the roll-up's `filter` tests (e.g. 'Service staff read account totals but not invoice rows'). Declared on the set's entry for the summary column, it turns that set's `security-rollup-source-unreadable` warning for the column into an `info` note quoting the reason, so `os lint --strict` passes; every other finding is unchanged. The runtime does not read the key, but the entry that carries it is an ordinary declaring entry: it votes `readable: true` in the field merge (only declaring sets vote, and the most permissive vote wins), so on a set that had no entry for the column, adding one to carry the reason restores the column for holders whose other sets mask it. A blank reason is refused, and so is a reason beside `readable: false`, an entry that declares no read to acknowledge. | --- From c317e3ad4df270a3aa6e1ee98b1596215b599e3c Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 17 Nov 2026 14:03:51 +0000 Subject: [PATCH 10/12] feat(studio): the landing panel's switched-off action rows open where the action is switched A switched-off action row of the Customizations in this environment panel opened the action's item page, which an action declared inside its object does not have. It now opens that object's Actions view when an object holds the action, through the same object read the landing line uses. Co-Authored-By: Claude Claude-Session: https://claude.ai/code/session_01WGufziD6XhBNH9acXaG2Me --- .../34724-action-switch-moves-to-studio.md | 2 +- ...Landing.customizationCounts-28566.test.tsx | 24 +++++++++++++++++++ ...erLanding.envCustomizations-34714.test.tsx | 22 +++++++++++++++++ .../views/studio-design/BuilderLanding.tsx | 2 +- .../LandingCustomizationsPanel.tsx | 10 ++++++-- .../studio-design/landingCustomizations-io.ts | 12 ++++++++-- 6 files changed, 66 insertions(+), 6 deletions(-) diff --git a/.changeset/34724-action-switch-moves-to-studio.md b/.changeset/34724-action-switch-moves-to-studio.md index 764402dc7e9..003f878ce3f 100644 --- a/.changeset/34724-action-switch-moves-to-studio.md +++ b/.changeset/34724-action-switch-moves-to-studio.md @@ -21,7 +21,7 @@ Before this change, the deployment's on/off switch for an installed app's action - On the object's Actions view in Studio, a read-only app package's vendor action carries a "Switched on / off for this deployment" switch, the flow switch's twin. A switched-off action is marked in the list. A refusal is the server's sentence, shown verbatim; a caller the deployment's posture walls off sees the switch disabled with the reason. - A standalone `action` item's page in Studio's "All metadata" area carries the same switch. - The platform's own actions (any action a kernel package ships) carry no switch anywhere. When the package list cannot be read, no switch is offered. -- Studio's landing leads to them: an app's "N switched off" count opens the switched-off action (one) or the action list (several), and when that does not land on an action (several, or flows among them), the line names each switched-off action as a link, three at most, then a "more" link to the list. An action its object holds opens on that object's Actions view (a new `?action=` beside `?surface=object:` in the Data pillar selects it), since an action declared inside its object has no page of its own; any other action opens its own page. +- Studio's landing leads to them: an app's "N switched off" count opens the switched-off action (one) or the action list (several), and when that does not land on an action (several, or flows among them), the line names each switched-off action as a link, three at most, then a "more" link to the list. An action its object holds opens on that object's Actions view (a new `?action=` beside `?surface=object:` in the Data pillar selects it), since an action declared inside its object has no page of its own; any other action opens its own page. The landing's "Customizations in this environment" panel links its switched-off action rows the same way. The doors are unchanged: the read is the `sys_metadata_activation` ledger, the write is `POST /api/v1/actions/_activation/:object/:action` with body `{ enabled }`. diff --git a/ui/packages/app-shell/src/views/studio-design/BuilderLanding.customizationCounts-28566.test.tsx b/ui/packages/app-shell/src/views/studio-design/BuilderLanding.customizationCounts-28566.test.tsx index 4ad4dff24bc..92ec3772602 100644 --- a/ui/packages/app-shell/src/views/studio-design/BuilderLanding.customizationCounts-28566.test.tsx +++ b/ui/packages/app-shell/src/views/studio-design/BuilderLanding.customizationCounts-28566.test.tsx @@ -396,6 +396,30 @@ describe('Studio landing: "m switched off" leads to the switched-off actions (ob ]); }); + it('the "Customizations in this environment" panel row of an action its object holds opens that object\'s Actions view too', async () => { + packages.list = [SHOWCASE]; + stubWire( + { + 'com.example.showcase': servedOff('com.example.showcase', [ + { type: 'action', name: 'showcase_embedded_probe' }, + { type: 'action', name: 'showcase_portfolio_snapshot' }, + ]), + }, + { 'com.example.showcase': [TASK_OBJECT] }, + ); + renderLanding(); + await readLine(); + const rows = await waitFor(() => { + const found = screen.getAllByTestId('studio-landing-env-customization'); + expect(found).toHaveLength(2); + return found; + }); + expect(rows.map((r) => r.querySelector('a')?.getAttribute('href'))).toEqual([ + embeddedPath, + '/studio/com.example.showcase/metadata/action/showcase_portfolio_snapshot', + ]); + }); + it('no object list read when nothing switched off is an action', async () => { packages.list = [SHOWCASE]; const { requested } = stubWire({ 'com.example.showcase': servedOff('com.example.showcase', [{ type: 'flow', name: 'showcase_nightly' }]) }); diff --git a/ui/packages/app-shell/src/views/studio-design/BuilderLanding.envCustomizations-34714.test.tsx b/ui/packages/app-shell/src/views/studio-design/BuilderLanding.envCustomizations-34714.test.tsx index dbdede99dda..ef58384cf2b 100644 --- a/ui/packages/app-shell/src/views/studio-design/BuilderLanding.envCustomizations-34714.test.tsx +++ b/ui/packages/app-shell/src/views/studio-design/BuilderLanding.envCustomizations-34714.test.tsx @@ -329,6 +329,28 @@ describe('the panel’s rows and labels (objectstack#34714)', () => { ]); }); + it('a switched-off action opens where it is switched: its object\'s Actions view when an object holds it, else its own page (objectstack#34724)', () => { + const read = { + overrides: [], + extensions: [], + switchedOff: [ + { type: 'action', name: 'clone_opportunity' }, + { type: 'action', name: 'export_all' }, + ], + }; + const hrefs = (objects?: Record) => + customizationRowsOf(HOTCRM, read, objects).map((r) => [r.name, r.href]); + expect(hrefs({ clone_opportunity: 'opportunity' })).toEqual([ + ['clone_opportunity', '/studio/app.objectstack.hotcrm/data?surface=object%3Aopportunity&action=clone_opportunity'], + ['export_all', '/studio/app.objectstack.hotcrm/metadata/action/export_all'], + ]); + // With no object read (none made, or it failed), every action opens its own page. + expect(hrefs()).toEqual([ + ['clone_opportunity', '/studio/app.objectstack.hotcrm/metadata/action/clone_opportunity'], + ['export_all', '/studio/app.objectstack.hotcrm/metadata/action/export_all'], + ]); + }); + it('labels come from the app’s own list of each type with rows, a field’s from its object; a failed list keeps the names', async () => { const { loadCustomizationLabels: real } = await vi.importActual( './landingCustomizations-io', diff --git a/ui/packages/app-shell/src/views/studio-design/BuilderLanding.tsx b/ui/packages/app-shell/src/views/studio-design/BuilderLanding.tsx index 3bb426026e5..b644cda20f4 100644 --- a/ui/packages/app-shell/src/views/studio-design/BuilderLanding.tsx +++ b/ui/packages/app-shell/src/views/studio-design/BuilderLanding.tsx @@ -236,7 +236,7 @@ export function BuilderLanding(): React.ReactElement { const customizationReads = React.useMemo(() => { const out: Record = {}; for (const [id, line] of Object.entries(customizationLines)) { - out[id] = line.kind === 'read' ? { kind: 'read', read: line.read } : line; + out[id] = line.kind === 'read' ? { kind: 'read', read: line.read, actionObjects: line.actionObjects } : line; } return out; }, [customizationLines]); diff --git a/ui/packages/app-shell/src/views/studio-design/LandingCustomizationsPanel.tsx b/ui/packages/app-shell/src/views/studio-design/LandingCustomizationsPanel.tsx index da7a639407f..1a26c7cc879 100644 --- a/ui/packages/app-shell/src/views/studio-design/LandingCustomizationsPanel.tsx +++ b/ui/packages/app-shell/src/views/studio-design/LandingCustomizationsPanel.tsx @@ -26,6 +26,7 @@ import { Search } from 'lucide-react'; import { t, tFormat } from '../metadata-admin/i18n.js'; import { useMetadataClient } from '../metadata-admin/useMetadata.js'; import type { PackageCustomizations } from './packageCustomizations-io.js'; +import type { ActionObjects } from './switchedOffActionTargets.js'; import { customizationRowsOf, loadCustomizationLabels, @@ -34,7 +35,12 @@ import { /** One app's read, as the landing holds it. */ export type AppCustomizationRead = - | { kind: 'read'; read: Pick } + | { + kind: 'read'; + read: Pick; + /** objectstack#34724 — the object holding each switched-off action (`readActionObjects`). */ + actionObjects?: ActionObjects; + } | { kind: 'failed'; message: string }; /** How many rows the panel shows before "Show all". */ @@ -79,7 +85,7 @@ export function LandingCustomizationsPanel({ () => apps.flatMap((app) => { const r = reads[app.id]; - return r?.kind === 'read' ? customizationRowsOf(app, r.read) : []; + return r?.kind === 'read' ? customizationRowsOf(app, r.read, r.actionObjects) : []; }), [apps, reads], ); diff --git a/ui/packages/app-shell/src/views/studio-design/landingCustomizations-io.ts b/ui/packages/app-shell/src/views/studio-design/landingCustomizations-io.ts index 77e44c9006d..f2e2e5aaccf 100644 --- a/ui/packages/app-shell/src/views/studio-design/landingCustomizations-io.ts +++ b/ui/packages/app-shell/src/views/studio-design/landingCustomizations-io.ts @@ -32,6 +32,7 @@ import { resolveI18nLabel, type I18nLabel } from '@objectstack/spec/ui'; import type { PackageCustomizations } from './packageCustomizations-io.js'; import { studioMetadataAreaPath } from './metadataArea.js'; +import { switchedOffActionPath, type ActionObjects } from './switchedOffActionTargets.js'; /** How a row changed the app. */ export type CustomizationMode = 'changed' | 'added' | 'switchedOff'; @@ -62,10 +63,17 @@ export interface CustomizationRow { const itemHref = (appId: string, type: string, name: string) => `${studioMetadataAreaPath(appId)}/${encodeURIComponent(type)}/${encodeURIComponent(name)}`; -/** The rows one app's served answer makes, in the served order: changed, added, switched off. */ +/** + * The rows one app's served answer makes, in the served order: changed, added, + * switched off. `actionObjects` (objectstack#34724) names the object holding + * each switched-off action: such an action opens on its object's Actions view, + * since one declared inside its object has no item page; any other action + * opens its own page, as every other type does. + */ export function customizationRowsOf( app: { id: string; name: string }, read: Pick, + actionObjects?: ActionObjects, ): CustomizationRow[] { const rows: CustomizationRow[] = []; for (const o of read.overrides) { @@ -105,7 +113,7 @@ export function customizationRowsOf( type: s.type, name: s.name, labelKey: `${s.type}:${s.name}`, - href: itemHref(app.id, s.type, s.name), + href: s.type === 'action' ? switchedOffActionPath(app.id, s.name, actionObjects?.[s.name]) : itemHref(app.id, s.type, s.name), }); } return rows; From 8390b4f5fb4bfec6d678077ec5b5bb8b08ac8387 Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 17 Nov 2026 15:12:58 +0000 Subject: [PATCH 11/12] test(studio): pay the lint import at collection in the action deep-link pin Co-Authored-By: Claude Claude-Session: https://claude.ai/code/session_01WGufziD6XhBNH9acXaG2Me --- .../studio-design/DataPillar.actionDeepLink-34724.test.tsx | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ui/packages/app-shell/src/views/studio-design/DataPillar.actionDeepLink-34724.test.tsx b/ui/packages/app-shell/src/views/studio-design/DataPillar.actionDeepLink-34724.test.tsx index 51e9f18c91e..08ad786a6a8 100644 --- a/ui/packages/app-shell/src/views/studio-design/DataPillar.actionDeepLink-34724.test.tsx +++ b/ui/packages/app-shell/src/views/studio-design/DataPillar.actionDeepLink-34724.test.tsx @@ -16,6 +16,8 @@ */ import '@testing-library/jest-dom/vitest'; +// The source under test reaches `import('@objectstack/lint')`: paid here, at collection, never inside a test's clock. +import '@objectstack/lint'; import * as React from 'react'; import { afterEach, describe, expect, it, vi } from 'vitest'; import { render, screen, fireEvent, cleanup, act } from '@testing-library/react'; From 5122812f3e18e2e5529223e1433db5d733649297 Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 17 Nov 2026 16:09:33 +0000 Subject: [PATCH 12/12] fix(app-shell): the Studio surface mirror drops ?action= once another surface opens A landing link to an embedded action carries ?action= beside ?surface=. The mirror kept it when the author picked another object, so a reload or a shared copy opened that object on its Actions view. The mirror now drops the key whenever the surface it writes differs from the one in the URL; its first write after a deep link names the same surface and keeps it. Pinned on the real Data pillar; ablating the drop turns the pin red. Co-Authored-By: Claude Claude-Session: https://claude.ai/code/session_01WGufziD6XhBNH9acXaG2Me --- .../DataPillar.actionDeepLink-34724.test.tsx | 34 ++++++++++++++++--- .../views/studio-design/useSurfaceDeepLink.ts | 11 ++++-- 2 files changed, 39 insertions(+), 6 deletions(-) diff --git a/ui/packages/app-shell/src/views/studio-design/DataPillar.actionDeepLink-34724.test.tsx b/ui/packages/app-shell/src/views/studio-design/DataPillar.actionDeepLink-34724.test.tsx index 08ad786a6a8..4114bee8ca1 100644 --- a/ui/packages/app-shell/src/views/studio-design/DataPillar.actionDeepLink-34724.test.tsx +++ b/ui/packages/app-shell/src/views/studio-design/DataPillar.actionDeepLink-34724.test.tsx @@ -12,7 +12,10 @@ * (its inspector shows its label, not the first action's); * - CONTROL: the same link without `action=` opens the object on Records, as * before, with no action inspector; - * - the param is read once: picking another view afterwards stays there. + * - the param is read once: picking another view afterwards stays there; + * - the param leaves the URL once another object opens, so a reload or a + * shared copy never opens that object on an action (seat L2 S4); the first + * write, naming the deep-linked object, keeps it. */ import '@testing-library/jest-dom/vitest'; @@ -20,8 +23,8 @@ import '@testing-library/jest-dom/vitest'; import '@objectstack/lint'; import * as React from 'react'; import { afterEach, describe, expect, it, vi } from 'vitest'; -import { render, screen, fireEvent, cleanup, act } from '@testing-library/react'; -import { MemoryRouter } from 'react-router-dom'; +import { render, screen, fireEvent, cleanup, act, waitFor } from '@testing-library/react'; +import { MemoryRouter, useSearchParams } from 'react-router-dom'; import { MetadataClient } from '@object-ui/data-objectstack'; import { ActionSchema } from '@objectstack/spec/ui'; @@ -80,7 +83,10 @@ const fetchImpl = vi.fn(async (_url: string, init?: RequestInit) => { const client = new MetadataClient({ baseUrl: 'http://test.local', fetch: fetchImpl as unknown as typeof fetch }); Object.assign(client, { - list: vi.fn(async () => [{ name: 'showcase_task', label: 'Task' }]), + list: vi.fn(async () => [ + { name: 'showcase_task', label: 'Task' }, + { name: 'showcase_note', label: 'Note' }, + ]), listDrafts: vi.fn(async () => []), layered: vi.fn(async () => ({ effective: objectDef, code: objectDef })), getDraft: vi.fn(async () => null), @@ -144,10 +150,17 @@ const TASK = { actions: [ARCHIVE, SEND], }; +/** The URL the pillar mirrored back: what a reload or a shared copy opens. */ +function UrlProbe(): React.ReactElement { + const [params] = useSearchParams(); + return {params.toString()}; +} + function mountAt(search: string): void { objectDef = TASK; render( + , ); @@ -182,4 +195,17 @@ describe('Studio data page — `?action=` opens the object\'s Actions view on th }); expect(screen.queryByText(L('engine.inspector.action.label'), { selector: 'label' })).not.toBeInTheDocument(); }); + + it('drops `action=` from the URL once another object opens, and keeps it until then', async () => { + mountAt('?surface=object%3Ashowcase_task&action=showcase_task_send'); + expect(await labelInput()).toHaveValue('Send'); + const url = () => new URLSearchParams(screen.getByTestId('url').textContent ?? ''); + // The mirror's first write names the deep-linked object: the key stays. + expect(url().get('surface')).toBe('object:showcase_task'); + expect(url().get('action')).toBe('showcase_task_send'); + + fireEvent.click(screen.getByRole('button', { name: 'Note' })); + await waitFor(() => expect(url().get('surface')).toBe('object:showcase_note')); + expect(url().has('action')).toBe(false); + }); }); diff --git a/ui/packages/app-shell/src/views/studio-design/useSurfaceDeepLink.ts b/ui/packages/app-shell/src/views/studio-design/useSurfaceDeepLink.ts index a990600b168..27c80c09a4e 100644 --- a/ui/packages/app-shell/src/views/studio-design/useSurfaceDeepLink.ts +++ b/ui/packages/app-shell/src/views/studio-design/useSurfaceDeepLink.ts @@ -76,7 +76,8 @@ export const DESIGNER_SURFACE_VIEW_PARAM = 'view'; * with that action selected. Studio's landing links a switched-off action * that lives in its object's `actions[]` here, since such an action has no * item page of its own and its switch is on the object's Actions view. A key - * of its own, for the reason `nav` is one. + * of its own, for the reason `nav` is one. Never written by the mirror, and + * dropped by it once another surface opens. */ export const DESIGNER_SURFACE_ACTION_PARAM = 'action'; @@ -134,7 +135,13 @@ export function useSurfaceDeepLinkMirror(current: SurfaceTarget | null | undefin setSearchParams( (prev) => { const next = new URLSearchParams(prev); - next.set(DESIGNER_SURFACE_PARAM, formatSurfaceParam({ type, name })); + const surface = formatSurfaceParam({ type, name }); + // objectstack#34724 — `?action=` was written for the surface it came + // with: once another surface opens, it is dropped, so a reload or a + // shared copy never opens the new surface on an action view. The + // first write after a deep link names that same surface and keeps it. + if (prev.get(DESIGNER_SURFACE_PARAM) !== surface) next.delete(DESIGNER_SURFACE_ACTION_PARAM); + next.set(DESIGNER_SURFACE_PARAM, surface); // objectui#11774 — the entry travels with its target, and a surface // with no entry id clears it, so a `nav` left by an earlier selection // never qualifies a target it was not written for.