From 285d2848449b24dcbd50ef90fc579c67cd51bc6d Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 24 Nov 2026 04:11:18 +0000 Subject: [PATCH 1/6] fix(core): the offboarding hand-over's owner_id follows the object's Change Owner switch Claude-Session: https://claude.ai/code/session_01QSeKYnUnriLNg19SxQdg2p Co-authored-by: Claude --- packages/core/src/security/index.ts | 1 + .../src/security/user-assigned-work.test.ts | 129 ++++++++++++++---- .../core/src/security/user-assigned-work.ts | 115 ++++++++++------ 3 files changed, 178 insertions(+), 67 deletions(-) diff --git a/packages/core/src/security/index.ts b/packages/core/src/security/index.ts index 1862f9ee57a..aa9840cb8fc 100644 --- a/packages/core/src/security/index.ts +++ b/packages/core/src/security/index.ts @@ -693,6 +693,7 @@ export { type UserAssignedWorkField, type UserWorkEngine, type UserAssignedWorkCount, + type UserAssignedWorkHoldReason, type UserAssignedWorkSummary, type UserWorkFailureDescriber, type UserWorkTransferFailure, diff --git a/packages/core/src/security/user-assigned-work.test.ts b/packages/core/src/security/user-assigned-work.test.ts index 2a840828418..7a06ced0e5b 100644 --- a/packages/core/src/security/user-assigned-work.test.ts +++ b/packages/core/src/security/user-assigned-work.test.ts @@ -2,7 +2,8 @@ import { describe, it, expect } from 'vitest'; import { assertEngineUpdateDispatch } from '@objectstack/metadata-core'; -import { AUDIT_FIELD_DEFS, OWNER_FIELD_DEF } from '@objectstack/spec/data'; +import { AUDIT_FIELD_DEFS, OWNER_FIELD_DEF, resolveUserActionTransfer } from '@objectstack/spec/data'; +import { changeOwnerOffReason } from './change-record-owner.js'; import { countUserAssignedWork, transferUserAssignedWork, @@ -35,10 +36,10 @@ describe('[#30205] userAssignedWorkFields', () => { const { fields, truncated } = userAssignedWorkFields([ticket, account, grant, managed]); expect(truncated).toBe(false); expect(fields).toEqual([ - { object: 'ticket', field: 'owner_id', multiple: false }, - { object: 'ticket', field: 'assignee', multiple: false }, - { object: 'ticket', field: 'watchers', multiple: true }, - { object: 'account', field: 'owner_id', multiple: false }, + { object: 'ticket', field: 'owner_id', multiple: false, transferable: true }, + { object: 'ticket', field: 'assignee', multiple: false, transferable: true }, + { object: 'ticket', field: 'watchers', multiple: true, transferable: false, reason: 'multi_valued' }, + { object: 'account', field: 'owner_id', multiple: false, transferable: true }, ]); }); @@ -47,7 +48,7 @@ describe('[#30205] userAssignedWorkFields', () => { // (`system`) that stays assignable, so `system` alone cannot exclude it. expect({ system: OWNER_FIELD_DEF.system, readonly: OWNER_FIELD_DEF.readonly }).toEqual({ system: true, readonly: false }); const { fields } = userAssignedWorkFields([{ name: 'deal', fields: { owner_id: OWNER_FIELD_DEF, ...AUDIT_FIELD_DEFS } }]); - expect(fields).toEqual([{ object: 'deal', field: 'owner_id', multiple: false }]); + expect(fields).toEqual([{ object: 'deal', field: 'owner_id', multiple: false, transferable: true }]); }); it('[ADR-0153 D4] leaves a synced object out — a user field on a pulled row is source data, not reassignable work', () => { @@ -138,7 +139,7 @@ describe('[#30205] countUserAssignedWork', () => { objects: [ { object: 'ticket', field: 'owner_id', count: 2, transferable: true }, { object: 'ticket', field: 'assignee', count: 2, transferable: true }, - { object: 'ticket', field: 'watchers', count: 2, transferable: false }, + { object: 'ticket', field: 'watchers', count: 2, transferable: false, reason: 'multi_valued' }, { object: 'account', field: 'owner_id', count: 1, transferable: true }, ], total: 7, @@ -260,8 +261,9 @@ describe('[#30205] transferUserAssignedWork', () => { }); }); -// A master and its `controlled_by_parent` detail. The detail's owner is the -// person who did the work, not who holds it: its access follows the master. +// A master and its `controlled_by_parent` detail. The detail declares no +// `userActions.transfer`, so its Change Owner switch takes the default its +// sharing model implies: off. const expenseReport = { name: 'expense_report', sharingModel: 'private', @@ -289,34 +291,83 @@ function expenseSeed(): Record { }; } -describe('a controlled_by_parent detail keeps its owner in the hand-over', () => { - it('leaves the detail\'s owner_id out of the roster; its own user fields and the master\'s owner stay', () => { +/** The roster's verdict on an object's `owner_id`, or `undefined` when it is not in the roster. */ +const ownerEntry = (def: unknown) => + userAssignedWorkFields([def]).fields.find((f) => f.field === 'owner_id'); + +// [#35399] The hand-over's owner column follows the object's Change Owner +// switch. Subsumes the #35344 interim pin, which left a detail's owner out of +// the roster: it is now counted, marked `transfer_off`, and never moved. +describe('[#35399] owner_id follows the object\'s Change Owner switch (userActions.transfer)', () => { + it('derived default on a detail: its owner is counted as not transferable (transfer_off); its own user field and the master\'s owner stay transferable', () => { expect(userAssignedWorkFields([expenseReport, expenseLine]).fields).toEqual([ - { object: 'expense_report', field: 'owner_id', multiple: false }, - { object: 'expense_report', field: 'approver', multiple: false }, - { object: 'expense_line', field: 'approver', multiple: false }, + { object: 'expense_report', field: 'owner_id', multiple: false, transferable: true }, + { object: 'expense_report', field: 'approver', multiple: false, transferable: true }, + { object: 'expense_line', field: 'owner_id', multiple: false, transferable: false, reason: 'transfer_off' }, + { object: 'expense_line', field: 'approver', multiple: false, transferable: true }, ]); }); - it('reads the sharing model where the access gates read it, the nested spot included', () => { - const nested = { name: 'expense_line', security: { sharingModel: 'controlled_by_parent' }, fields: expenseLine.fields }; - expect(userAssignedWorkFields([nested]).fields.map((f) => f.field)).toEqual(['approver']); + it('switch on: a detail that turns userActions.transfer on hands its owner over', () => { + for (const transfer of [true, { enabled: true }]) { + expect(ownerEntry({ ...expenseLine, userActions: { transfer } })).toEqual( + { object: 'expense_line', field: 'owner_id', multiple: false, transferable: true }, + ); + } + }); + + it('switch off: an object that turns userActions.transfer off keeps its owner; its app-authored user field is still handed over', () => { + for (const transfer of [false, { enabled: false }]) { + const fields = userAssignedWorkFields([{ ...expenseReport, userActions: { transfer } }]).fields; + expect(fields).toEqual([ + { object: 'expense_report', field: 'owner_id', multiple: false, transferable: false, reason: 'transfer_off' }, + { object: 'expense_report', field: 'approver', multiple: false, transferable: true }, + ]); + } }); - it('twin: the same object under any other sharing model hands its owner over', () => { + it('twin: the detail under any other sharing model hands its owner over', () => { for (const sharingModel of ['private', 'public_read', 'public_read_write', undefined]) { - const owned = { ...expenseLine, sharingModel }; - expect(userAssignedWorkFields([owned]).fields.map((f) => f.field)).toEqual(['owner_id', 'approver']); + expect(ownerEntry({ ...expenseLine, sharingModel })?.transferable).toBe(true); + } + }); + + it('an owner_id the platform does not provide is app-authored work: the switch does not govern it', () => { + // `systemFields: false` gives the object no platform owner, so an author's + // own `owner_id` user field is like any other app user field. + const appOwner = { ...expenseLine, systemFields: false, fields: { owner_id: { type: 'user' } } }; + expect(ownerEntry(appOwner)).toEqual({ object: 'expense_line', field: 'owner_id', multiple: false, transferable: true }); + }); + + it('one rule with Change Owner: the roster\'s owner verdict is resolveUserActionTransfer\'s, and Change Owner refuses exactly what the hand-over keeps', () => { + const defs: Array> = [ + expenseReport, + expenseLine, + { ...expenseLine, userActions: { transfer: true } }, + { ...expenseLine, userActions: { transfer: { enabled: true, visibleWhen: 'record.status == "open"' } } }, + { ...expenseLine, userActions: { transfer: { visibleWhen: 'true' } } }, + { ...expenseReport, userActions: { transfer: false } }, + { ...expenseReport, userActions: { transfer: { enabled: false } } }, + { ...expenseReport, sharingModel: undefined }, + // Off-spec nested spot: both doors read the switch only, so they agree here too. + { name: 'expense_line', security: { sharingModel: 'controlled_by_parent' }, fields: expenseLine.fields }, + ]; + for (const def of defs) { + const entry = ownerEntry(def); + expect(entry, JSON.stringify(def)).toBeDefined(); + expect(entry!.transferable, JSON.stringify(def)).toBe(resolveUserActionTransfer(def).enabled); + expect(changeOwnerOffReason(String(def.name), def) === undefined, JSON.stringify(def)).toBe(entry!.transferable); } }); - it('does not count the detail\'s owner_id', async () => { + it('counts the switched-off owner as not transferable, beside the transferable holdings', async () => { const summary = await countUserAssignedWork(fakeEngine(expenseSeed(), { configs: EXPENSE_CONFIGS }), 'u_gone', CALLER); expect(summary.objects).toEqual([ { object: 'expense_report', field: 'owner_id', count: 1, transferable: true }, + { object: 'expense_line', field: 'owner_id', count: 2, transferable: false, reason: 'transfer_off' }, { object: 'expense_line', field: 'approver', count: 1, transferable: true }, ]); - expect(summary.total).toBe(2); + expect(summary.total).toBe(4); }); it('moves the master\'s owner and the detail\'s approver, never the detail\'s owner', async () => { @@ -326,12 +377,13 @@ describe('a controlled_by_parent detail keeps its owner in the hand-over', () => { object: 'expense_report', field: 'owner_id', updated: 1, failed: 0, failures: [] }, { object: 'expense_line', field: 'approver', updated: 1, failed: 0, failures: [] }, ]); + // `remaining` counts only what a further call could move. expect(report.remaining).toBe(0); expect(engine.tables.get('expense_report')![0].owner_id).toBe('u_next'); expect(engine.tables.get('expense_line')!.map((r) => [r.owner_id, r.approver])).toEqual([['u_gone', 'u_next'], ['u_gone', 'u_x']]); - // No write named the detail's owner column. - const ownerWrites = engine.calls.filter((c) => c.op === 'update' && c.object === 'expense_line'); - expect(ownerWrites).toHaveLength(1); + // No read or write named the detail's owner column. + expect(engine.calls.some((c) => c.object === 'expense_line' && c.op !== 'count' && 'owner_id' in (c.where ?? {}))).toBe(false); + expect(engine.calls.filter((c) => c.op === 'update' && c.object === 'expense_line')).toHaveLength(1); }); it('a transfer naming the detail alone moves its approver and leaves its owner', async () => { @@ -341,4 +393,31 @@ describe('a controlled_by_parent detail keeps its owner in the hand-over', () => expect(engine.tables.get('expense_line')!.map((r) => r.owner_id)).toEqual(['u_gone', 'u_gone']); expect(engine.calls.some((c) => c.op === 'find' && c.object === 'expense_line' && 'owner_id' in (c.where ?? {}))).toBe(false); }); + + it('switch on: the detail\'s owner is moved like any other', async () => { + const opened = { ...expenseLine, userActions: { transfer: true } }; + const engine = fakeEngine(expenseSeed(), { configs: { ...EXPENSE_CONFIGS, expenseLine: opened } }); + const report = await transferUserAssignedWork(engine, 'u_gone', 'u_next', CALLER, { objects: ['expense_line'] }); + expect(report.objects).toEqual([ + { object: 'expense_line', field: 'owner_id', updated: 2, failed: 0, failures: [] }, + { object: 'expense_line', field: 'approver', updated: 1, failed: 0, failures: [] }, + ]); + expect(engine.tables.get('expense_line')!.map((r) => r.owner_id)).toEqual(['u_next', 'u_next']); + }); + + it('optional master: a row whose master reference is empty follows the object\'s switch too — counted, never moved', async () => { + const optional = { + ...expenseLine, + fields: { ...expenseLine.fields, report: { type: 'master_detail', reference: 'expense_report', required: false } }, + }; + const rows = expenseSeed(); + rows.expense_line.push({ id: 'l3', report: null, owner_id: 'u_gone', approver: 'u_x' }); + const configs = { ...EXPENSE_CONFIGS, expenseLine: optional }; + const summary = await countUserAssignedWork(fakeEngine(rows, { configs }), 'u_gone', CALLER); + expect(summary.objects.find((o) => o.object === 'expense_line' && o.field === 'owner_id')) + .toEqual({ object: 'expense_line', field: 'owner_id', count: 3, transferable: false, reason: 'transfer_off' }); + const engine = fakeEngine(rows, { configs }); + await transferUserAssignedWork(engine, 'u_gone', 'u_next', CALLER); + expect(engine.tables.get('expense_line')!.find((r) => r.id === 'l3')!.owner_id).toBe('u_gone'); + }); }); diff --git a/packages/core/src/security/user-assigned-work.ts b/packages/core/src/security/user-assigned-work.ts index d34b3ede65e..3a1561593fe 100644 --- a/packages/core/src/security/user-assigned-work.ts +++ b/packages/core/src/security/user-assigned-work.ts @@ -26,29 +26,39 @@ * is a grant, not work, and moving it would move the person's permissions. * - a column the platform registers but provisions no storage for (an injected * anchor on a federated object, `unprovisionedInjectedColumns`). - * - the owner column (`owner_id`) of a `controlled_by_parent` detail. On a - * detail the owner records who did the work, not who holds it: on a - * timesheet, an expense or a line item it is the person who did it, and - * handing it over would make the successor appear to have done the - * leaver's work. A detail row that names its master is reached through - * that master (ADR-0055), so handing the master over hands over its - * access. A detail row whose master reference is empty, on an OPTIONAL - * master (ADR-0055 as amended), has no master: its owner reads and writes - * it, beside View All / Modify All on the detail. That row's owner is left - * out too, because the skip is per object. After a ban only View All / - * Modify All holders reach such a row, and a holder of Modify All on the - * detail moves it by filtering the detail by owner and editing the owner - * by hand. The maintainer's ruling on Change Owner turns transfer off on a - * detail by default; until an object can say otherwise, the hand-over - * leaves the detail's owner where it is. The detail's own user fields (an - * `approver`, an `assignee`) are app-authored work and still count. It is - * left out rather than counted as not transferable: the only reason the - * count answer can give today (`transferable: false`) reads as a - * multi-valued field. * - * A multi-valued user field is counted (any member names the user) but never - * transferred: replacing one member of a list is a different edit from - * reassigning a record, and the answer says `transferable: false`. + * ## Counted, but not handed over + * + * Two kinds of holding are counted and never moved, and the count answer says + * which (`transferable: false` with a {@link UserAssignedWorkHoldReason}): + * + * - `multi_valued`: a multi-valued user field (any member names the user). + * Replacing one member of a list is a different edit from reassigning a + * record. + * - `transfer_off`: the platform owner column (`owner_id`) of an object whose + * Change Owner switch is off. Whether an object's owner can be handed to + * someone else is a property of the object, not of this door, so the + * hand-over asks the one resolution Change Owner asks + * (`resolveUserActionTransfer`, `@objectstack/spec/data`; + * `change-record-owner.ts` refuses by it): an object that turns + * `userActions.transfer` off keeps its owners where they are, and an object + * that omits the switch takes the default its `sharingModel` implies. That + * default is off on a `controlled_by_parent` detail, where the owner is + * usually the person who did the work (a timesheet, an expense, a line + * item) and a row that names its master is reached through that master + * (ADR-0055), so handing the master over hands over its access. An author + * whose detail has a real owner (a contact under an account) turns the + * switch on, and the hand-over then moves that owner like any other. The + * rule is per object, so on a switched-off detail with an OPTIONAL master + * (ADR-0055 as amended) a row whose master reference is empty keeps its + * owner too; a holder of Modify All on the detail moves it by hand. The + * switch governs only `owner_id`, and only where it is the platform's + * reassignable owner (`isTransferEligible`): the object's own user fields + * (an `approver`, an `assignee`) are app-authored work and are handed over + * whatever the switch says. + * + * Both are still counted, so the administrator knows the records exist and + * why they stay. * * ## Whose reads and writes * @@ -72,7 +82,12 @@ * ban itself neither waits for nor depends on any of this: a ban can be urgent. */ -import { referenceTargetOf, unprovisionedInjectedColumns } from '@objectstack/spec/data'; +import { + isTransferEligible, + referenceTargetOf, + resolveUserActionTransfer, + unprovisionedInjectedColumns, +} from '@objectstack/spec/data'; import { SystemFieldName } from '@objectstack/spec/system'; import { isUserBanInForce, USER_BAN_FIELDS } from './user-ban.js'; @@ -80,19 +95,21 @@ import { isUserBanInForce, USER_BAN_FIELDS } from './user-ban.js'; const USER_OBJECT = 'sys_user'; /** - * Does this object's access follow a master record (`sharingModel: - * 'controlled_by_parent'`, ADR-0055)? Read on the flat and the nested spot, - * as the access gates read it (`masterGovernsRowWrites` in - * `@objectstack/plugin-security`, `effectiveSharingModel` in - * `@objectstack/plugin-sharing`), so the hand-over treats as a detail exactly - * the objects whose rows the gates answer through a master. Those packages - * depend on this one and `@objectstack/spec` exports no object-level - * predicate, so the reading is spelled here; a raw-registered object can - * reach the registry without the parse, which is why the nested spot is read. + * Why a counted holding is not handed over: a multi-valued user field, or the + * owner column of an object whose Change Owner switch is off. */ -function accessFollowsMaster(obj: ObjectLike): boolean { - const model = obj.sharingModel ?? obj.security?.sharingModel; - return model === 'controlled_by_parent'; +export type UserAssignedWorkHoldReason = 'multi_valued' | 'transfer_off'; + +/** + * Does this object keep its platform owner where it is? True when `owner_id` + * is the platform's reassignable owner (`isTransferEligible`) and the object's + * Change Owner switch resolves off (`resolveUserActionTransfer`, the one + * resolution Change Owner refuses by). An `owner_id` that is not the platform + * owner (an author-declared field on an object the platform gives no owner) + * answers false: that field is app-authored work. + */ +function ownerTransferOff(obj: unknown): boolean { + return isTransferEligible(obj) && !resolveUserActionTransfer(obj).enabled; } /** At most this many (object, field) pairs are counted in one answer. */ @@ -110,14 +127,16 @@ export interface UserAssignedWorkField { field: string; /** A multi-valued user field: counted, never transferred. */ multiple: boolean; + /** Whether a hand-over moves this field's records. */ + transferable: boolean; + /** Why not, present exactly when `transferable` is false. */ + reason?: UserAssignedWorkHoldReason; } interface ObjectLike { name?: unknown; managedBy?: unknown; fields?: unknown; - sharingModel?: unknown; - security?: { sharingModel?: unknown } | null; } /** @@ -136,15 +155,22 @@ export function userAssignedWorkFields( if (obj.managedBy !== undefined && obj.managedBy !== null) continue; if (!obj.fields || typeof obj.fields !== 'object') continue; const phantom = new Set(unprovisionedInjectedColumns(obj as any)); - const detail = accessFollowsMaster(obj); + let ownerOff: boolean | undefined; for (const [field, def] of Object.entries(obj.fields as Record)) { if (phantom.has(field)) continue; - if (detail && field === SystemFieldName.OWNER_ID) continue; if (referenceTargetOf(def) !== USER_OBJECT) continue; const d = def as { readonly?: unknown; multiple?: unknown }; if (d.readonly === true) continue; if (fields.length >= cap) return { fields, truncated: true }; - fields.push({ object: name, field, multiple: d.multiple === true }); + const multiple = d.multiple === true; + const reason: UserAssignedWorkHoldReason | undefined = multiple + ? 'multi_valued' + : field === SystemFieldName.OWNER_ID && (ownerOff ??= ownerTransferOff(obj)) + ? 'transfer_off' + : undefined; + fields.push(reason + ? { object: name, field, multiple, transferable: false, reason } + : { object: name, field, multiple, transferable: true }); } } return { fields, truncated: false }; @@ -182,7 +208,10 @@ export interface UserAssignedWorkCount { object: string; field: string; count: number; + /** Whether a hand-over moves these records. */ transferable: boolean; + /** Why not, present exactly when `transferable` is false. */ + reason?: UserAssignedWorkHoldReason; } /** What {@link countUserAssignedWork} answers. */ @@ -218,7 +247,9 @@ export async function countUserAssignedWork( continue; } if (!(count > 0)) continue; - objects.push({ object: ref.object, field: ref.field, count, transferable: !ref.multiple }); + objects.push(ref.reason + ? { object: ref.object, field: ref.field, count, transferable: false, reason: ref.reason } + : { object: ref.object, field: ref.field, count, transferable: true }); total += count; } return { userId, objects, total, truncated, unreadable: [...unreadable] }; @@ -357,7 +388,7 @@ export async function transferUserAssignedWork( const only = options.objects && options.objects.length > 0 ? new Set(options.objects) : undefined; const { fields } = userAssignedWorkFields(servedObjects(engine)); - const refs = fields.filter((ref) => !ref.multiple && (!only || only.has(ref.object))); + const refs = fields.filter((ref) => ref.transferable && (!only || only.has(ref.object))); let budget = options.rowCap ?? USER_WORK_TRANSFER_ROW_CAP; const objects: UserWorkTransferOutcome[] = []; let updated = 0; From 595f49221de2bb426a82be417c0335ddadff386b Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 24 Nov 2026 04:13:46 +0000 Subject: [PATCH 2/6] fix(console): the ban dialog words a kept owner by why it stays Claude-Session: https://claude.ai/code/session_01QSeKYnUnriLNg19SxQdg2p Co-authored-by: Claude --- packages/client/src/index.ts | 22 ++++++++++--- packages/rest/src/rest-server.ts | 9 +++-- ...ParamDialog.banAssignedWork-30205.test.tsx | 33 ++++++++++++++++++- .../src/views/UserAssignedWorkPanel.tsx | 15 +++++++-- ui/packages/i18n/src/locales/ar.ts | 1 + ui/packages/i18n/src/locales/de.ts | 1 + ui/packages/i18n/src/locales/en.ts | 1 + ui/packages/i18n/src/locales/es.ts | 1 + ui/packages/i18n/src/locales/fr.ts | 1 + ui/packages/i18n/src/locales/ja.ts | 1 + ui/packages/i18n/src/locales/ko.ts | 1 + ui/packages/i18n/src/locales/pt-BR.ts | 1 + ui/packages/i18n/src/locales/ru.ts | 1 + ui/packages/i18n/src/locales/zh-Hans.ts | 1 + ui/packages/i18n/src/locales/zh-Hant.ts | 1 + 15 files changed, 78 insertions(+), 12 deletions(-) diff --git a/packages/client/src/index.ts b/packages/client/src/index.ts index 061fec98789..ef40186d3b0 100644 --- a/packages/client/src/index.ts +++ b/packages/client/src/index.ts @@ -253,11 +253,21 @@ export interface MetaItemsListOptions { /** * [#30205] `security.assignedWork.count`'s answer: per object and user field, - * how many records hold the user, as the caller can read them. + * how many records hold the user, as the caller can read them. A row with + * `transferable: false` is counted but never handed over, and `reason` says + * why: `multi_valued` (a multi-valued user field) or `transfer_off` (the owner + * field of an object whose Change Owner switch, `userActions.transfer`, is off). */ export interface UserAssignedWorkSummary { userId: string; - objects: Array<{ object: string; field: string; count: number; transferable: boolean }>; + objects: Array<{ + object: string; + field: string; + count: number; + transferable: boolean; + /** Why the row is not handed over; present exactly when `transferable` is false. */ + reason?: 'multi_valued' | 'transfer_off'; + }>; total: number; truncated: boolean; unreadable: string[]; @@ -7042,9 +7052,11 @@ export class ObjectStackClient { assignedWork: { /** * Per object and user field (the owner field and every app user - * field), how many records hold `userId`. Objects the caller cannot - * read are named in `unreadable`; `truncated` says more fields exist - * than were counted. + * field), how many records hold `userId`, each with whether + * `transfer` moves them and, when it does not, why (`reason`): a + * multi-valued field, or the owner field of an object whose Change + * Owner switch is off. Objects the caller cannot read are named in + * `unreadable`; `truncated` says more fields exist than were counted. */ count: async (userId: string): Promise => { const res = await this.fetch( diff --git a/packages/rest/src/rest-server.ts b/packages/rest/src/rest-server.ts index 81dac7a37d2..85b94795b08 100644 --- a/packages/rest/src/rest-server.ts +++ b/packages/rest/src/rest-server.ts @@ -6541,9 +6541,12 @@ export class RestServer { * * The first answers, per object and user field, how many records hold the * user (the owner field and every app user field), counted as the caller - * can read them. The second hands up to 500 of those records to another - * active user per call, each as an ordinary update under the caller's - * context, and answers what moved, what failed and how many remain. + * can read them, and per row whether the second moves them and, when it + * does not, why (a multi-valued field, or the owner field of an object + * whose Change Owner switch is off). The second hands up to 500 of the + * transferable records to another active user per call, each as an + * ordinary update under the caller's context, and answers what moved, what + * failed and how many remain. * Neither touches the ban. `@objectstack/core`'s `user-assigned-work.ts` * holds the rules. */ diff --git a/ui/packages/app-shell/src/views/ActionParamDialog.banAssignedWork-30205.test.tsx b/ui/packages/app-shell/src/views/ActionParamDialog.banAssignedWork-30205.test.tsx index 5c574f10d20..f500f5ac829 100644 --- a/ui/packages/app-shell/src/views/ActionParamDialog.banAssignedWork-30205.test.tsx +++ b/ui/packages/app-shell/src/views/ActionParamDialog.banAssignedWork-30205.test.tsx @@ -67,7 +67,7 @@ const SUMMARY = { objects: [ { object: 'showcase_project', field: 'owner_id', count: 3, transferable: true }, { object: 'showcase_field_zoo', field: 'f_user', count: 2, transferable: true }, - { object: 'showcase_field_zoo', field: 'f_users', count: 2, transferable: false }, + { object: 'showcase_field_zoo', field: 'f_users', count: 2, transferable: false, reason: 'multi_valued' as const }, ], total: 7, truncated: false, @@ -128,6 +128,37 @@ describe('the ban dialog says how many records the user holds (objectstack#30205 .not.toContain('console.assignedWork.notTransferable'); }); + it('objectstack#35399: an owner the object keeps (Change Owner off) is counted as owned and worded by its reason, never as a multi-valued field', async () => { + count = vi.fn(async () => ({ + ...SUMMARY, + objects: [ + { object: 'showcase_invoice_line', field: 'owner_id', count: 4, transferable: false, reason: 'transfer_off' as const }, + { object: 'showcase_field_zoo', field: 'f_users', count: 2, transferable: false, reason: 'multi_valued' as const }, + ], + total: 6, + })); + mount(); + const summary = await screen.findByTestId('user-assigned-work-summary'); + expect(within(summary).getByText('console.assignedWork.summary {"total":6,"owned":4,"assigned":2}')).toBeTruthy(); + const kept = screen.getByTestId('user-assigned-work-row-showcase_invoice_line-owner_id'); + expect(within(kept).getByTestId('user-assigned-work-not-transferable').textContent).toBe('console.assignedWork.ownerKept'); + const multi = screen.getByTestId('user-assigned-work-row-showcase_field_zoo-f_users'); + expect(within(multi).getByTestId('user-assigned-work-not-transferable').textContent).toBe('console.assignedWork.notTransferable'); + // Nothing here can be handed over, so the hand-over is not offered. + expect(screen.queryByTestId('user-assigned-work-handover')).toBeNull(); + }); + + it('objectstack#35399: every UI locale words the kept owner with its own sentence, apart from the multi-valued one', async () => { + const { builtInLocales } = await import('@object-ui/i18n/locales'); + const locales = Object.entries(builtInLocales as Record); + expect(locales.length).toBeGreaterThan(0); + for (const [lang, catalog] of locales) { + const words = catalog?.console?.assignedWork; + expect(typeof words?.ownerKept, lang).toBe('string'); + expect(words.ownerKept, lang).not.toBe(words.notTransferable); + } + }); + it('owned is the owner_id rows only; every other user field is assigned', () => { expect(splitAssignedWork(SUMMARY)).toEqual({ owned: 3, assigned: 4 }); expect(splitAssignedWork({ ...SUMMARY, objects: [{ object: 'a', field: 'owner', count: 5, transferable: true }], total: 5 })) diff --git a/ui/packages/app-shell/src/views/UserAssignedWorkPanel.tsx b/ui/packages/app-shell/src/views/UserAssignedWorkPanel.tsx index 0676564680b..7096befd66d 100644 --- a/ui/packages/app-shell/src/views/UserAssignedWorkPanel.tsx +++ b/ui/packages/app-shell/src/views/UserAssignedWorkPanel.tsx @@ -18,8 +18,10 @@ * answer as it came: it computes no count of its own. * * "Owned" is the records whose `owner_id` names the user; every other user - * field is "assigned". A multi-valued user field is counted but cannot be - * handed over here (the server answers `transferable: false`). + * field is "assigned". A row the server answers `transferable: false` for is + * counted but not handed over here, and the panel words it by the server's + * `reason`: a multi-valued user field, or the owner of an object whose Change + * Owner switch is off (that object keeps its records' owner). * * ## Never in the ban's way * @@ -239,6 +241,11 @@ export function UserAssignedWorkPanel({ userId }: UserAssignedWorkPanelProps) { ); } +/** The sentence a not-transferable row is worded with, chosen by why the server holds it back. */ +function notTransferableKey(reason: AssignedWorkSummary['objects'][number]['reason']): string { + return reason === 'transfer_off' ? 'console.assignedWork.ownerKept' : 'console.assignedWork.notTransferable'; +} + function AssignedWorkSummaryView({ summary, objectText, @@ -268,7 +275,9 @@ function AssignedWorkSummaryView({ {t('console.assignedWork.row', { object: objectText(row.object), field: fieldText(row.object, row.field) })} {!row.transferable && ( - {t('console.assignedWork.notTransferable')} + + {t(notTransferableKey(row.reason))} + )} {row.count} diff --git a/ui/packages/i18n/src/locales/ar.ts b/ui/packages/i18n/src/locales/ar.ts index 69e3622f00e..ed288d9159c 100644 --- a/ui/packages/i18n/src/locales/ar.ts +++ b/ui/packages/i18n/src/locales/ar.ts @@ -3058,6 +3058,7 @@ const ar = { summary: 'يحتفظ بـ {{total}} من السجلات التي يمكنك قراءتها: مالك لـ {{owned}}، ومُسند إليه {{assigned}}.', row: '{{object}} · {{field}}', notTransferable: 'يضم هذا الحقل عدة أشخاص، لذا لا يمكن تسليمه هنا.', + ownerKept: 'لا يُسلَّم: يحتفظ هذا الكائن بمالك كل سجل (خيار «تغيير المالك» معطّل له).', truncated: 'لم تُعدّ كل حقول المستخدم؛ قد يحتفظ هذا الشخص بالمزيد.', unreadable: 'لم تُعدّ لأنك لا تستطيع قراءتها: {{objects}}', handoverTo: 'تسليم إلى', diff --git a/ui/packages/i18n/src/locales/de.ts b/ui/packages/i18n/src/locales/de.ts index 5a42d07297e..1cd16700729 100644 --- a/ui/packages/i18n/src/locales/de.ts +++ b/ui/packages/i18n/src/locales/de.ts @@ -2770,6 +2770,7 @@ const de = { summary: 'Datensätze, die Sie lesen können: {{total}}. Besitzer: {{owned}}, zugewiesen: {{assigned}}.', row: '{{object}} · {{field}}', notTransferable: 'Enthält mehrere Personen und kann hier nicht übergeben werden.', + ownerKept: 'Wird nicht übergeben: Dieses Objekt behält den Besitzer jedes Datensatzes bei („Besitzer ändern“ ist dafür aus).', truncated: 'Nicht alle Benutzerfelder wurden gezählt; diese Person kann weitere halten.', unreadable: 'Nicht gezählt, weil Sie sie nicht lesen können: {{objects}}', handoverTo: 'Übergeben an', diff --git a/ui/packages/i18n/src/locales/en.ts b/ui/packages/i18n/src/locales/en.ts index 260974ee6a8..9b50ab09b6a 100644 --- a/ui/packages/i18n/src/locales/en.ts +++ b/ui/packages/i18n/src/locales/en.ts @@ -3449,6 +3449,7 @@ const en = { summary: 'Records you can read: {{total}}, owns {{owned}}, assigned {{assigned}}.', row: '{{object}} · {{field}}', notTransferable: 'Lists several people, so it cannot be handed over here.', + ownerKept: 'Not handed over: this object keeps the owner of each record (Change Owner is off for it).', truncated: 'Not every user field was counted; this person may hold more.', unreadable: 'Not counted, because you cannot read them: {{objects}}', handoverTo: 'Hand over to', diff --git a/ui/packages/i18n/src/locales/es.ts b/ui/packages/i18n/src/locales/es.ts index ddd409a9379..8973a200f1e 100644 --- a/ui/packages/i18n/src/locales/es.ts +++ b/ui/packages/i18n/src/locales/es.ts @@ -2844,6 +2844,7 @@ const es = { summary: 'Registros que usted puede leer: {{total}}. En propiedad: {{owned}}, asignados: {{assigned}}.', row: '{{object}} · {{field}}', notTransferable: 'Admite varias personas, así que no se puede traspasar aquí.', + ownerKept: 'No se traspasa: este objeto conserva el propietario de cada registro («Cambiar propietario» está desactivado en él).', truncated: 'No se contaron todos los campos de usuario; esta persona puede tener más.', unreadable: 'No contados porque no puede leerlos: {{objects}}', handoverTo: 'Traspasar a', diff --git a/ui/packages/i18n/src/locales/fr.ts b/ui/packages/i18n/src/locales/fr.ts index d4773b6cb88..25febfbcbb6 100644 --- a/ui/packages/i18n/src/locales/fr.ts +++ b/ui/packages/i18n/src/locales/fr.ts @@ -2840,6 +2840,7 @@ const fr = { summary: 'Enregistrements que vous pouvez lire : {{total}}. En propriété : {{owned}}, assignés : {{assigned}}.', row: '{{object}} · {{field}}', notTransferable: 'Ce champ contient plusieurs personnes et ne peut pas être transféré ici.', + ownerKept: 'Non transféré : cet objet conserve le propriétaire de chaque enregistrement (« Changer de propriétaire » y est désactivé).', truncated: 'Tous les champs utilisateur n’ont pas été comptés ; cette personne peut en détenir davantage.', unreadable: 'Non comptés, car vous ne pouvez pas les lire : {{objects}}', handoverTo: 'Transférer à', diff --git a/ui/packages/i18n/src/locales/ja.ts b/ui/packages/i18n/src/locales/ja.ts index fd62978d577..15558892974 100644 --- a/ui/packages/i18n/src/locales/ja.ts +++ b/ui/packages/i18n/src/locales/ja.ts @@ -2772,6 +2772,7 @@ const ja = { summary: 'あなたが読み取れるレコードのうち {{total}} 件を担当しています: 所有 {{owned}} 件、割り当て {{assigned}} 件。', row: '{{object}} · {{field}}', notTransferable: '複数の人を入れられる項目のため、ここでは引き継げません。', + ownerKept: '引き継がれません。このオブジェクトでは各レコードの所有者は変わりません(所有者の変更がオフになっています)。', truncated: 'すべてのユーザー項目は数えていません。担当レコードはさらにある可能性があります。', unreadable: '読み取り権限がないため数えていません: {{objects}}', handoverTo: '引き継ぎ先', diff --git a/ui/packages/i18n/src/locales/ko.ts b/ui/packages/i18n/src/locales/ko.ts index 1d6ddf07f16..eb826315c09 100644 --- a/ui/packages/i18n/src/locales/ko.ts +++ b/ui/packages/i18n/src/locales/ko.ts @@ -2770,6 +2770,7 @@ const ko = { summary: '읽을 수 있는 레코드 중 {{total}}건을 맡고 있습니다: 소유 {{owned}}건, 할당 {{assigned}}건.', row: '{{object}} · {{field}}', notTransferable: '여러 사람을 넣는 필드라 여기서 인계할 수 없습니다.', + ownerKept: '인계되지 않습니다. 이 개체는 각 레코드의 소유자를 그대로 유지합니다(소유자 변경이 꺼져 있음).', truncated: '모든 사용자 필드를 세지는 않았습니다. 더 맡고 있을 수 있습니다.', unreadable: '읽기 권한이 없어 세지 않았습니다: {{objects}}', handoverTo: '인계 대상', diff --git a/ui/packages/i18n/src/locales/pt-BR.ts b/ui/packages/i18n/src/locales/pt-BR.ts index 50ac83b45a8..d491044589a 100644 --- a/ui/packages/i18n/src/locales/pt-BR.ts +++ b/ui/packages/i18n/src/locales/pt-BR.ts @@ -2839,6 +2839,7 @@ const pt = { summary: 'Registros que você pode ler: {{total}}. Em propriedade: {{owned}}, atribuídos: {{assigned}}.', row: '{{object}} · {{field}}', notTransferable: 'Aceita várias pessoas, por isso não pode ser transferido aqui.', + ownerKept: 'Não é transferido: este objeto mantém o proprietário de cada registro ("Alterar proprietário" está desativado nele).', truncated: 'Nem todos os campos de usuário foram contados; esta pessoa pode ter mais.', unreadable: 'Não contados porque você não pode lê-los: {{objects}}', handoverTo: 'Transferir para', diff --git a/ui/packages/i18n/src/locales/ru.ts b/ui/packages/i18n/src/locales/ru.ts index df5b86e31c3..42b8f2839c4 100644 --- a/ui/packages/i18n/src/locales/ru.ts +++ b/ui/packages/i18n/src/locales/ru.ts @@ -2920,6 +2920,7 @@ const ru = { summary: 'Записей, которые вы можете читать: {{total}}; владелец — {{owned}}, назначено — {{assigned}}.', row: '{{object}} · {{field}}', notTransferable: 'Поле содержит нескольких человек, поэтому его нельзя передать здесь.', + ownerKept: 'Не передаётся: этот объект сохраняет владельца каждой записи («Сменить владельца» для него отключено).', truncated: 'Подсчитаны не все пользовательские поля; записей может быть больше.', unreadable: 'Не подсчитаны, так как у вас нет доступа на чтение: {{objects}}', handoverTo: 'Передать', diff --git a/ui/packages/i18n/src/locales/zh-Hans.ts b/ui/packages/i18n/src/locales/zh-Hans.ts index e59964a7316..990f721f3e0 100644 --- a/ui/packages/i18n/src/locales/zh-Hans.ts +++ b/ui/packages/i18n/src/locales/zh-Hans.ts @@ -2935,6 +2935,7 @@ const zh = { summary: '你可读取的记录中有 {{total}} 条在此人手上:拥有 {{owned}} 条,被指派 {{assigned}} 条。', row: '{{object}} · {{field}}', notTransferable: '该字段可填多人,无法在此交接。', + ownerKept: '不会交接:该对象的记录负责人保持不变(该对象已关闭“更改负责人”)。', truncated: '并非所有用户字段都已统计,此人手上可能还有更多记录。', unreadable: '以下对象你无权读取,未计入:{{objects}}', handoverTo: '交接给', diff --git a/ui/packages/i18n/src/locales/zh-Hant.ts b/ui/packages/i18n/src/locales/zh-Hant.ts index 30f5cec4fdd..f8538166e27 100644 --- a/ui/packages/i18n/src/locales/zh-Hant.ts +++ b/ui/packages/i18n/src/locales/zh-Hant.ts @@ -2935,6 +2935,7 @@ const zhHant = { summary: '你可讀取的記錄中有 {{total}} 條在此人手上:擁有 {{owned}} 條,被指派 {{assigned}} 條。', row: '{{object}} · {{field}}', notTransferable: '該欄位可填多人,無法在此交接。', + ownerKept: '不會交接:該物件的記錄負責人保持不變(該物件已關閉「更改負責人」)。', truncated: '並非所有使用者欄位都已統計,此人手上可能還有更多記錄。', unreadable: '以下物件你無權讀取,未計入:{{objects}}', handoverTo: '交接給', From bcd457b49e49ffa202e7a930a810165f8ae0e2bb Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 24 Nov 2026 04:22:10 +0000 Subject: [PATCH 3/6] test(dogfood), docs: a target the caller cannot read answers as a missing user; the hand-over docs read the switch Claude-Session: https://claude.ai/code/session_01QSeKYnUnriLNg19SxQdg2p Co-authored-by: Claude --- .../35399-handover-follows-transfer-switch.md | 23 +++++++++++ content/docs/api/data-api.mdx | 6 ++- .../docs/permissions/administrator-guide.mdx | 38 +++++++++++-------- .../change-owner-endpoint.dogfood.test.ts | 36 ++++++++++++++++++ 4 files changed, 86 insertions(+), 17 deletions(-) create mode 100644 .changeset/35399-handover-follows-transfer-switch.md diff --git a/.changeset/35399-handover-follows-transfer-switch.md b/.changeset/35399-handover-follows-transfer-switch.md new file mode 100644 index 00000000000..c6ef7d2fbcf --- /dev/null +++ b/.changeset/35399-handover-follows-transfer-switch.md @@ -0,0 +1,23 @@ +--- +'@objectstack/core': minor +'@objectstack/client': minor +'@object-ui/app-shell': minor +'@object-ui/i18n': minor +--- + +fix(core, console): a banned user's hand-over follows each object's Change Owner switch, and the ban dialog says why a record stays + +Clause-②: no +Metadata-protocol: semantic + +An object's Change Owner switch (`userActions.transfer`) now also decides whether the offboarding hand-over (`GET` / `POST /api/v1/security/users/USER_ID/assigned-work[/transfer]`) moves the object's `owner_id`. The hand-over reads the same resolution the Change Owner action refuses by (`resolveUserActionTransfer`), so the two never disagree: + +- An object that turns the switch off keeps its records' owners where they are. Before, the hand-over moved them. +- A `controlled_by_parent` detail that leaves the switch out keeps its owner (the default is off there), as before. A detail that sets `userActions.transfer: true` now has its owner handed over like any other object. Before, every detail's owner was skipped. +- The object's own user fields (an approver, an assignee) are handed over whatever the switch says. + +A kept owner is still counted. Before, a detail's owner was left out of the count; now its row answers `transferable: false` with `reason: 'transfer_off'`. A multi-valued user field answers `reason: 'multi_valued'`. `reason` is a new optional member of each `objects[]` row in `security.assignedWork.count`'s answer (`UserAssignedWorkSummary` in `@objectstack/client`, `UserAssignedWorkHoldReason` in `@objectstack/core`). It is present exactly when `transferable` is false. + +The ban dialog words each kept row by its reason. A kept owner reads "Not handed over: this object keeps the owner of each record (Change Owner is off for it)." (zh: 不会交接:该对象的记录负责人保持不变(该对象已关闭“更改负责人”)。). Before, every row that could not be handed over read "Lists several people", which is false for an owner. The new `console.assignedWork.ownerKept` key is in all eleven UI locales. + +To keep the old hand-over of an object you switched off, set `userActions.transfer` back on for it. The switch still gates only these two actions: a plain `owner_id` write (an import, a hook, a `PATCH`) still needs only the transfer grant. diff --git a/content/docs/api/data-api.mdx b/content/docs/api/data-api.mdx index 33eb55edf00..27738c6e1fd 100644 --- a/content/docs/api/data-api.mdx +++ b/content/docs/api/data-api.mdx @@ -472,8 +472,10 @@ Offered only on an object the platform gives a reassignable owner and whose `userActions.transfer` switch is on. The switch defaults to on, and to off on a `controlled_by_parent` detail. Any other object is refused as a whole with `403 CHANGE_OWNER_DISABLED`, whoever asks, a `modifyAllRecords` holder -included. The switch gates this action only: a plain `owner_id` update (an -import, a hook, a `PATCH`) still needs the transfer grant and nothing else. +included. The same switch decides whether a banned user's hand-over +(`/api/v1/security/users/USER_ID/assigned-work`) moves the object's owners. +It gates these two actions only: a plain `owner_id` update (an import, a hook, +a `PATCH`) still needs the transfer grant and nothing else. **Body**: exactly one target, and an optional notification. diff --git a/content/docs/permissions/administrator-guide.mdx b/content/docs/permissions/administrator-guide.mdx index 4e1c0cf94f0..97cc24c1109 100644 --- a/content/docs/permissions/administrator-guide.mdx +++ b/content/docs/permissions/administrator-guide.mdx @@ -114,21 +114,29 @@ hand: validation rules and hooks apply. It answers what moved, what failed and how many remain; call it again until `remaining` is 0. -The owner field of a detail object (`sharingModel: 'controlled_by_parent'`) -is neither counted nor moved. On a detail the owner records who did the work -(the person on a timesheet, the spender on an expense line), not who holds -it; handing it over would make the successor appear to have done that work. -A detail row that names its master is reached through that master, so hand -over the master record instead. The detail's other user fields, such as an -approver, are counted and moved as usual. - -One row class has no master to hand over: a detail row whose master reference -is empty, on a detail whose master is optional (declared `required: false`). -Its owner reads and writes it, beside holders of View All / Modify All on the -detail. Its owner is not counted or moved either, so after the ban only View -All / Modify All holders reach it. To give such rows to someone else, a holder -of Modify All on the detail filters the detail by owner and edits the owner by -hand. +Some holdings are counted but not moved, and the count says why on each row +(`transferable: false` with a `reason`): + +- `multi_valued`: a user field that lists several people. Replacing one person + in a list is a different edit from reassigning a record. +- `transfer_off`: the owner field of an object whose Change Owner switch, + `userActions.transfer`, is off. The hand-over follows the same switch as the + Change Owner action, so an object that turns it off keeps its records' + owners where they are. The switch defaults to off on a detail object + (`sharingModel: 'controlled_by_parent'`): there the owner usually records + who did the work (the person on a timesheet, the spender on an expense + line), and a detail row that names its master is reached through that + master, so hand over the master record instead. A detail whose owner really + holds the record (a contact under an account) sets `userActions.transfer: + true`, and the hand-over then moves its owner like any other. The rule is + per object: on a switched-off detail whose master is optional (declared + `required: false`), a row with an empty master reference keeps its owner + too, and after the ban only holders of View All / Modify All on the detail + reach it; a holder of Modify All moves it by filtering the detail by owner + and editing the owner by hand. + +The switch governs only the platform owner field: an object's other user +fields, such as an approver, are counted and moved as usual. The hand-over is optional and never delays the ban. Once a user is banned, a new record or edit that sets a user field to them is refused with the field diff --git a/packages/qa/dogfood/test/change-owner-endpoint.dogfood.test.ts b/packages/qa/dogfood/test/change-owner-endpoint.dogfood.test.ts index 636b88a646a..5cb97d3eec9 100644 --- a/packages/qa/dogfood/test/change-owner-endpoint.dogfood.test.ts +++ b/packages/qa/dogfood/test/change-owner-endpoint.dogfood.test.ts @@ -104,6 +104,42 @@ describe('[#35402] Change Owner doors on the showcase', () => { if (line) expect((await ql.findOne('showcase_invoice_line', { where: { id }, context: SYS }))?.owner_id).toBe(line.owner_id); }); + it('a new owner the caller cannot read answers exactly as one that exists nowhere: 404 reference_not_found, and the owner stays', async () => { + // `assertAssignableUser`, the check this door shares with the offboarding + // hand-over. A user outside the caller's organization is one the member + // baseline does not let the caller read. + const stranger = 'change_owner_stranger'; + const nobody = 'change_owner_no_such_user'; + await ql.insert('sys_user', { id: stranger, email: 'change-owner-stranger@verify.test', name: 'Stranger', email_verified: true }, { context: SYS }); + // Arming: the user exists, and the caller's own read door does not return it. + expect(await ql.findOne('sys_user', { where: { id: stranger }, context: SYS }), 'the stranger exists').toBeTruthy(); + const seen = await stack.apiAs(aliceToken, 'GET', `/data/sys_user/${stranger}`); + expect(seen.status, 'the caller cannot read the stranger').toBe(404); + + const note = await create(aliceToken, 'alice keeps this'); + const answer = async (ownerId: string) => { + const r = await stack.apiAs(aliceToken, 'POST', `${OBJ}/${note}/change-owner`, { ownerId }); + const body: any = await r.json(); + return { + status: r.status, + code: body.error?.code, + message: String(body.error?.message ?? '').replaceAll(ownerId, 'ID'), + fields: (body.error?.details?.fields ?? []).map((f: any) => [f.field, f.code]), + raw: JSON.stringify(body), + }; + }; + const unread = await answer(stranger); + const missing = await answer(nobody); + expect(unread.status, unread.raw).toBe(404); + expect(unread.code).toBe('RESOURCE_NOT_FOUND'); + expect(unread.fields).toEqual([['ownerId', 'reference_not_found']]); + // The one difference allowed is the id the caller itself sent. + const { raw: _u, ...unreadAnswer } = unread; + const { raw: _m, ...missingAnswer } = missing; + expect(unreadAnswer).toEqual(missingAnswer); + expect(await ownerOf(note)).toBe(aliceId); + }); + it('MEASURED: after a transfer the new owner reads and edits the record; the previous owner, still its creator, reads and edits nothing', async () => { const note = await create(aliceToken, 'alice hands this to bob'); const moved = await stack.apiAs(aliceToken, 'POST', `${OBJ}/${note}/change-owner`, { ownerId: bobId }); From 4947544c313c3efcab75d144daf7d41e565342e7 Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 24 Nov 2026 04:38:10 +0000 Subject: [PATCH 4/6] fix(i18n): zh-Hant regenerated from zh-Hans; the de paired-quote pin counts the new line Claude-Session: https://claude.ai/code/session_01QSeKYnUnriLNg19SxQdg2p Co-authored-by: Claude --- .../i18n/src/__tests__/de-quote-pairing-3876.test.ts | 8 ++++++-- ui/packages/i18n/src/locales/zh-Hant.ts | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/ui/packages/i18n/src/__tests__/de-quote-pairing-3876.test.ts b/ui/packages/i18n/src/__tests__/de-quote-pairing-3876.test.ts index 43bf8a8ed52..967f1b56561 100644 --- a/ui/packages/i18n/src/__tests__/de-quote-pairing-3876.test.ts +++ b/ui/packages/i18n/src/__tests__/de-quote-pairing-3876.test.ts @@ -480,7 +480,10 @@ describe('objectui#3876 — de pack closes „ with “ and not with a straight // 134 once objectstack-ai/objectstack#36758 named the design mode by its // door in `empty.appMenuEmptyDescription` („Layout // gestalten“) — one literal span. - expect(okSpans, 'correctly paired spans').toBe(134); + // 135 once objectstack-ai/objectstack#35399 added `console.assignedWork.ownerKept`, + // the ban dialog's line naming the action that is off („Besitzer ändern“) — + // one literal span. + expect(okSpans, 'correctly paired spans').toBe(135); }); it('keeps the count identity that replaces the card’s count(„) === count(“)', () => { @@ -617,7 +620,8 @@ describe('objectui#3876 — de pack closes „ with “ and not with a straight // `designMode.pins`, four more matched pairs. // 134 / 134 / 0 after objectstack-ai/objectstack#36758 named the design // mode „Layout gestalten“ in `empty.appMenuEmptyDescription`, one more pair. - expect({ open, close, rdq }).toEqual({ open: 134, close: 134, rdq: 0 }); + // 135 / 135 / 0 after objectstack-ai/objectstack#35399 added `console.assignedWork.ownerKept`. + expect({ open, close, rdq }).toEqual({ open: 135, close: 135, rdq: 0 }); // The durable shape: every „ closed by a “, every surplus “ an English // opener answered by a ”. Survived translating the two English values. expect(close).toBe(open + rdq); diff --git a/ui/packages/i18n/src/locales/zh-Hant.ts b/ui/packages/i18n/src/locales/zh-Hant.ts index f8538166e27..cc3ff7b8482 100644 --- a/ui/packages/i18n/src/locales/zh-Hant.ts +++ b/ui/packages/i18n/src/locales/zh-Hant.ts @@ -2935,7 +2935,7 @@ const zhHant = { summary: '你可讀取的記錄中有 {{total}} 條在此人手上:擁有 {{owned}} 條,被指派 {{assigned}} 條。', row: '{{object}} · {{field}}', notTransferable: '該欄位可填多人,無法在此交接。', - ownerKept: '不會交接:該物件的記錄負責人保持不變(該物件已關閉「更改負責人」)。', + ownerKept: '不會交接:該物件的記錄負責人保持不變(該物件已關閉“更改負責人”)。', truncated: '並非所有使用者欄位都已統計,此人手上可能還有更多記錄。', unreadable: '以下物件你無權讀取,未計入:{{objects}}', handoverTo: '交接給', From a31b2c96ffd4246b527a314014811f32f3769fbc Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 24 Nov 2026 05:09:25 +0000 Subject: [PATCH 5/6] test(console): load the locale packs at module top, outside the clocked window Claude-Session: https://claude.ai/code/session_01QSeKYnUnriLNg19SxQdg2p Co-authored-by: Claude --- .../views/ActionParamDialog.banAssignedWork-30205.test.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ui/packages/app-shell/src/views/ActionParamDialog.banAssignedWork-30205.test.tsx b/ui/packages/app-shell/src/views/ActionParamDialog.banAssignedWork-30205.test.tsx index f500f5ac829..6beab764001 100644 --- a/ui/packages/app-shell/src/views/ActionParamDialog.banAssignedWork-30205.test.tsx +++ b/ui/packages/app-shell/src/views/ActionParamDialog.banAssignedWork-30205.test.tsx @@ -49,6 +49,7 @@ vi.mock('@object-ui/fields', async (importOriginal) => ({ ), })); +import { builtInLocales } from '@object-ui/i18n/locales'; import { AdapterCtx, MetadataCtx } from '@object-ui/react'; import { ActionParamDialog } from './ActionParamDialog'; import { splitAssignedWork } from './userAssignedWork'; @@ -148,8 +149,7 @@ describe('the ban dialog says how many records the user holds (objectstack#30205 expect(screen.queryByTestId('user-assigned-work-handover')).toBeNull(); }); - it('objectstack#35399: every UI locale words the kept owner with its own sentence, apart from the multi-valued one', async () => { - const { builtInLocales } = await import('@object-ui/i18n/locales'); + it('objectstack#35399: every UI locale words the kept owner with its own sentence, apart from the multi-valued one', () => { const locales = Object.entries(builtInLocales as Record); expect(locales.length).toBeGreaterThan(0); for (const [lang, catalog] of locales) { From 36f2b3544a4225ec269999ac1cfcb8f65bac22c3 Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 24 Nov 2026 07:49:17 +0000 Subject: [PATCH 6/6] docs(changeset): name @objectstack/rest, and say what the count and the switch did before Claude-Session: https://claude.ai/code/session_01QSeKYnUnriLNg19SxQdg2p Co-authored-by: Claude --- .changeset/35399-handover-follows-transfer-switch.md | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.changeset/35399-handover-follows-transfer-switch.md b/.changeset/35399-handover-follows-transfer-switch.md index c6ef7d2fbcf..1ee54dc683a 100644 --- a/.changeset/35399-handover-follows-transfer-switch.md +++ b/.changeset/35399-handover-follows-transfer-switch.md @@ -1,6 +1,7 @@ --- '@objectstack/core': minor '@objectstack/client': minor +'@objectstack/rest': minor '@object-ui/app-shell': minor '@object-ui/i18n': minor --- @@ -10,7 +11,7 @@ fix(core, console): a banned user's hand-over follows each object's Change Owner Clause-②: no Metadata-protocol: semantic -An object's Change Owner switch (`userActions.transfer`) now also decides whether the offboarding hand-over (`GET` / `POST /api/v1/security/users/USER_ID/assigned-work[/transfer]`) moves the object's `owner_id`. The hand-over reads the same resolution the Change Owner action refuses by (`resolveUserActionTransfer`), so the two never disagree: +An object's Change Owner switch (`userActions.transfer`) now also decides whether the offboarding hand-over (`POST /api/v1/security/users/USER_ID/assigned-work/transfer`) moves the object's `owner_id`, and how the count (`GET /api/v1/security/users/USER_ID/assigned-work`) reports it. The hand-over reads the same resolution the Change Owner action refuses by (`resolveUserActionTransfer`), so the two never disagree: - An object that turns the switch off keeps its records' owners where they are. Before, the hand-over moved them. - A `controlled_by_parent` detail that leaves the switch out keeps its owner (the default is off there), as before. A detail that sets `userActions.transfer: true` now has its owner handed over like any other object. Before, every detail's owner was skipped. @@ -18,6 +19,6 @@ An object's Change Owner switch (`userActions.transfer`) now also decides whethe A kept owner is still counted. Before, a detail's owner was left out of the count; now its row answers `transferable: false` with `reason: 'transfer_off'`. A multi-valued user field answers `reason: 'multi_valued'`. `reason` is a new optional member of each `objects[]` row in `security.assignedWork.count`'s answer (`UserAssignedWorkSummary` in `@objectstack/client`, `UserAssignedWorkHoldReason` in `@objectstack/core`). It is present exactly when `transferable` is false. -The ban dialog words each kept row by its reason. A kept owner reads "Not handed over: this object keeps the owner of each record (Change Owner is off for it)." (zh: 不会交接:该对象的记录负责人保持不变(该对象已关闭“更改负责人”)。). Before, every row that could not be handed over read "Lists several people", which is false for an owner. The new `console.assignedWork.ownerKept` key is in all eleven UI locales. +The ban dialog words each kept row by its reason. A kept owner reads "Not handed over: this object keeps the owner of each record (Change Owner is off for it)." (zh: 不会交接:该对象的记录负责人保持不变(该对象已关闭“更改负责人”)。). A multi-valued row keeps its own sentence ("Lists several people, so it cannot be handed over here."), and a kept owner never shows it. The new `console.assignedWork.ownerKept` key is in all eleven UI locales. -To keep the old hand-over of an object you switched off, set `userActions.transfer` back on for it. The switch still gates only these two actions: a plain `owner_id` write (an import, a hook, a `PATCH`) still needs only the transfer grant. +To keep the old hand-over of an object you switched off, set `userActions.transfer` back on for it. Before this change the switch gated only the Change Owner action; it now gates that action and the hand-over, and nothing else: a plain `owner_id` write (an import, a hook, a `PATCH`) still needs only the transfer grant.