Skip to content

fix(platform-objects): show a user's manager and direct reports in Setup, prefill Set Manager, add Remove Manager - #36162

Merged
objectstack-fleet[bot] merged 5 commits into
mainfrom
claude/issue-36017-show-user-manager
Nov 21, 2026
Merged

objectstack-fleet[bot] merged 5 commits into
mainfrom
claude/issue-36017-show-user-manager

Conversation

@objectstack-fleet

Copy link
Copy Markdown
Contributor

Requested by Leehom · project thread
Fixes #36017

Clause-②: no
Metadata-protocol: none

维护者速读

  • 用户能看到什么变化:平台管理员在 Setup → 用户 → 打开某个用户时,详情页新增「汇报关系」一栏显示其经理、「直接下属」列表显示向其汇报的人;「设置经理」对话框打开时预先填好当前经理;新增「移除经理」按钮可清空经理(仅在该用户确有经理时出现)。
  • 为什么做:外部开发者反馈,管理员设置经理后在界面上找不到读回的地方,也无法把误设的经理移除;这影响审批路由与团队可见范围的维护。
  • 出错会怎样:最坏情况是管理员看到的经理/下属显示不准,或移除失败并看到服务端的拒绝提示;写入仍只经过原有的管理员接口,所有拒绝规则不变,改动可整体撤回。
  • 要你做什么:无

What changes

An admin who set a user's manager could not read it back anywhere in Setup (the value was stored correctly; the card measured it over the data API). Four parts, each on an existing declared mechanism, no spec key added:

  1. Details → Reporting Line section names manager_id (packages/platform-objects/src/pages/sys-user.page.ts). The field stays readonly: true (ADR-0092 D4); it is shown, not edited. Named "Reporting Line", not "Organization": the reporter mistook the Organizations tab (membership) for the org structure, and a section called "Organization" would repeat that. primary_business_unit_id (same field group) is deliberately left out: it is plugin-sharing's projection of sys_business_unit_member.is_primary, and the Business Units tab already lists the source rows with their primary flag.
  2. Details → Direct Reports: a record:related_list of sys_user on relationshipField: 'manager_id' (parent value id, the props default). It is read-only by construction: sys_user opens no create or delete (userActions: { edit: true }, apiMethods without create/delete), so the host offers neither New nor Remove. Labels in the page's 11 locales.
  3. Set Manager opens on the current manager: the managerId param is now field-backed on manager_id with defaultFromRow: true (the existing key; precedent sys_team_member's teamId). Measured: the console's resolver (ui/packages/fields/src/resolveActionParams.ts) seeds from field ?? name and carries type, target and label but never readonly, and paramToField builds the widget without it, so the picker stays editable. The record header stamps its record as the row; a list row is projected with every defaultFromRow seed field (@object-ui/core listViewPredicates). Request body unchanged: { userId, managerId }.
  4. Remove Manager (remove_user_manager, new action): posts the same endpoint with bodyExtra: { managerId: null } (the existing static-body key, merged last at both doors). Same requiredPermissions and the same standing term as Set Manager, then has(record.manager_id) && record.manager_id != null, so it is only offered while there is a manager to remove (the Ban / Unban row-state pattern). confirmText, no params, no ai block (an action after the ADR-0011 assessment stays human-only). ⛔ No client-side copy of any endpoint refusal (ruling record 6895645364 option A); the SCIM-held refusal applies to the clear at the endpoint.

Decision batch #127 item 1 is untouched: the manager is sys_user.manager_id alone; nothing reads or derives a business unit head.

Tests

  • packages/platform-objects/src/pages/sys-user-details-tab.test.ts: the section list (Reporting Line added) and a new top-level describe: the Details section holding manager_id, the Direct Reports list on sys_user / manager_id / parent value id (read through RecordRelatedListProps), labels in the tab's locales.
  • packages/platform-objects/src/identity/sys-user-set-manager-action.test.ts: the param is field-backed + defaultFromRow (replacing the old INLINE pin, whose read-only rationale was measured false), and a new describe for remove_user_manager: bodyExtra equal to { managerId: null } with the key present, no params, confirmText, gate keys equal to Set Manager's, the standing term first, the only record column read is manager_id, offered/hidden verdicts through the CEL engine, no ai block.
  • packages/runtime/src/platform-admin-action-gate.test.ts: a new describe driving the real declaration through the REST action door: an admin's click is forwarded to /api/v1/auth/admin/set-user-manager with userId and managerId present and null; a plain member is refused 403 and nothing is forwarded.

Ablation (one-shot, through scripts/ablation-replace.mjs, src-resolved in both suites): deleting the bodyExtra line turned the runtime door test and the platform-objects declaration test red; restore proven (blob == HEAD, git diff HEAD empty).

Acceptance notes

  • The record page reads the manager through the console's own read path (list route, filter by id, populate=manager_id), measured on a booted showcase: the populated manager_id comes back as the manager's record with name. The painted Console page was not observed in a browser (Console build not run); the details renderer's lookup display is pre-existing behaviour.
  • sys-user-set-manager-action.test.ts previously pinned the param INLINE because a field-backed param "may render read-only". Measured on ui/ at this tree: neither resolveActionParams nor paramToField carries readonly onto a param. The comment and the pin are rewritten with that reading.
  • Open PR feat(console): keep list column widths, row height and tab order in this browser only #36133 also edits sys-user.page.ts; overlap-check reports it merges cleanly with this branch.

Verification

  • Two-minute check: pnpm --filter @objectstack/platform-objects exec vitest run --maxWorkers=2 src/pages/sys-user-details-tab.test.ts src/identity/sys-user-set-manager-action.test.ts → 2 files, 25 tests pass.
  • Read first (by risk): packages/platform-objects/src/identity/sys-user.object.ts (the remove_user_manager block and the set_user_manager param), packages/platform-objects/src/pages/sys-user.page.ts (the Details tab), packages/runtime/src/platform-admin-action-gate.test.ts.
Local readings at head 30de59a
  • pnpm --filter @objectstack/platform-objects typecheck + pnpm --filter @objectstack/runtime typecheck (with their check:test-typecheck): exit 0, under the verify lock (VERDICT command-exit 0).
  • pnpm --filter @objectstack/platform-objects exec vitest run --maxWorkers=2: Test Files 125 passed (125), Tests 2126 passed (2126).
  • pnpm --filter @objectstack/runtime exec vitest run --maxWorkers=2 src/platform-admin-action-gate.test.ts: Test Files 1 passed (1), Tests 18 passed (18).
  • pnpm check:i18n: all ten extract packages in sync after node scripts/check-i18n-bundles.mjs --write; the ten translated locales carry hand-written remove_user_manager strings (their source-hash entries dropped by the next extract).
  • Derived gate families (dispatch-gates.mjs --commands, 67 with the changeset families): exit 0 except three NOT MEASURED, each a prerequisite refusal (exit 3), not a finding: check-plugin-teardown-shape.mjs --self-test (shallow clone cannot read its pinned fixture commit), check:dual-build-cjs-loads (needs the whole workspace built), check:type-check-debt (verify-lock queue timeout). CI runs all three.
Booted showcase, server-side measurement (own port, torn down)
  • Set Manager through the action door with the field-backed param: {"success":true,"data":{"userId":"usr_showcase_auditor_demo","managerId":"…","setBy":"…"}}.
  • GET /api/v1/data/sys_user/usr_showcase_auditor_demo?expand=manager_id and the console's list read (filter id, populate=manager_id): manager_id comes back as the manager's record, name: "Dev Admin"; without expansion it is the bare id.
  • Direct Reports read (filter manager_id = admin id): 2 rows; control (manager_id = Ada): 0 rows.
  • Served sys_user metadata keeps bodyExtra: {"managerId": null} and the param's field + defaultFromRow; served sys_user_detail carries Reporting Line, Direct Reports and relationshipField: manager_id.
  • POST /api/v1/actions/sys_user/remove_user_manager: {"success":true,"data":{"userId":"usr_showcase_auditor_demo","managerId":null,…}}; afterwards manager_id reads null and the admin's reports drop to 1.

Generated by Claude Code

…; prefill and clear it

Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FEkQ5okniknzVVR3KTSVr1
… and the Remove Manager clear

Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FEkQ5okniknzVVR3KTSVr1
… at the action door

Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FEkQ5okniknzVVR3KTSVr1
…ocale; changeset

Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FEkQ5okniknzVVR3KTSVr1
@github-actions github-actions Bot added size/m documentation Improvements or additions to documentation tests tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface labels Nov 21, 2026
@github-actions

github-actions Bot commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor

📓 Docs Drift Check

This PR changes 1 package(s): @objectstack/platform-objects, touching 7 documentable anchor(s).

34 hand-written doc(s) name something this change touched — list omitted above 15 rows. Re-derive on the tree named below: node scripts/docs-audit/affected-docs.mjs --json 146b6f9b6018b8144690338cf1cf0374407a4187.

⛔ 10 release-owned page(s) also affected — read-only, see AGENTS.md Documentation Guardrails.

What this run could not see
  • 2 anchor(s) matched too much of the corpus to be a work list: sys_user (symbol, 56 pages), sys_user (literal, 56 pages)
  • 2 name(s) were too generic to anchor anything (single lowercase words)
  • a page that states a rule by its inputs shares no identifier with the emitter that implements the rule, so an emitter-only diff cannot list it — not on this run and not on any run. Measured on fix(driver-sql): emit varchar(maxLength) for a text field a declared index keys on #11430: content/docs/protocol/objectql/types.mdx documents the text-family column mapping by the ObjectQL type names it maps FROM (text / textarea / html) while the diff changed createColumn; it went unlisted, and it was the page that diff falsified, in four places. No shared token exists to detect this on, so a rule your change carries has to be re-read by hand in the pages that restate it.
  • a key NAME is not a key, so the hand re-read the line above prescribes can land on the wrong schema. The same spelling is authorable on one governed type and a [REMOVED] tombstone on another for each of active, aria, joins, objects, template, tools and version (censused on [finding] tools is a key on BOTH AgentSchema (tombstoned, dead) and SkillSchema (live, cloud-attested), so a name-based search attributes skill examples to the agent key — it produced a false stop-the-line alarm on PR #19059 #19093 over the liveness ledger's governed types, top-level keys); nothing in a search result distinguishes the two, so a grep hit on a LIVE example reads as evidence about the DEAD key. Measured on fix(spec): the agent.tools liveness row says dead — it claimed live on a key the schema tombstoned #19059: content/docs/ai/agents.mdx was reported as contradicting the agent.tools tombstone over its tools: example at :161, which is inside the defineSkill({ block opened at :155 — the page was already correct. Settle ownership by PARSING the value against both schemas, never by the name: that literal PASSES SkillSchema, and as an AgentSchema it FAILS at tools with the tombstone prescription. ⛔ These names are not the whole class — a key retired through a .strict() guidance map leaves no tombstone in the walked shape and none of them here (tool.category, live as AIToolDefinition.category).

Coarse fallback — 3 page(s) merely mention a changed package (the pre-#9192 predicate, kept for the deliberately-wide backstop): node scripts/docs-audit/affected-docs.mjs --json 146b6f9b6018b8144690338cf1cf0374407a4187 → packageMentionDocs.

Which tree this was computed on

This run read content/docs from a6e95a80a673a240018f63b6a79a0df570ee6024 — the merge of head e06f4b85bf4d8d65aefdc4aaee3cd54992f05102 into base 146b6f9b6018b8144690338cf1cf0374407a4187, which is what actions/checkout gives a pull_request run. Not the PR head.

A worktree cut from an older main holds a different content/docs, so re-deriving there can legitimately return a different list — that is a different tree, not a wrong row. To answer on the same tree:

# while this PR is open — GitHub drops the merge commit once it closes
git fetch origin a6e95a80a673a240018f63b6a79a0df570ee6024 && git checkout a6e95a80a673a240018f63b6a79a0df570ee6024
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin 146b6f9b6018b8144690338cf1cf0374407a4187 e06f4b85bf4d8d65aefdc4aaee3cd54992f05102 && git checkout -B drift-repro 146b6f9b6018b8144690338cf1cf0374407a4187 && git merge --no-ff e06f4b85bf4d8d65aefdc4aaee3cd54992f05102

node scripts/docs-audit/affected-docs.mjs --json 146b6f9b6018b8144690338cf1cf0374407a4187

⚠️ That checkout carried uncommitted changes, so the commit above does not fully identify what was read.

Advisory only, and a precision-first one (#9192): a page is listed because it names a
symbol, wire route or SDK method this diff touched — not because it mentions a changed
package. Each row says which anchor put it there, so a wrong row is reportable rather than
merely annoying. To re-verify, run the docs-accuracy-audit workflow scoped to these files:
node scripts/docs-audit/affected-docs.mjs 146b6f9b6018b8144690338cf1cf0374407a4187 → pass the list as
args.docs, on the commit named under Which tree this was computed on.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#4 · os-project-manager · session_01FEkQ5okniknzVVR3KTSVr1

Final green head · area a4-D · 2026-11-21T17:40Z
Head: 30de59af71b9b50420784f2a4836eb628ccfca42
CI: 37 success, 16 skipped, 0 failed; check-expected-skips.mjs --pr 36162 OK (every skip in main's roster); mergeable clean.
Owed: L1 (L1-b). L2: none — the diff touches none of the four contract faces (Clause-②: no, no narrowing, no packages/spec/src/**, no governed path).
Dev report: comment 7066343422 on #36017.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#4 · os-project-manager · session_01FEkQ5oVqoTJkrRZcyZS4xd
L1-b · 2026-11-21T17:43Z

席位核对 — REWORK · head 30de59a (one test-only item; the rest is ACCEPT-ready)

REWORK item:

  1. packages/runtime/src/platform-admin-action-gate.test.ts, new case "a plain member is refused 403 at the door …": the refusal asserts status 403 and message text, but not the envelope code (ADR-0112; l1-review-checklist, "rejection cases assert code and status"). Add the code assertion on the REST refusal body. It should be PERMISSION_DENIED, which the file's own MCP twin pins for this gate. After the push I read only that delta.

What I checked, which carries to the ACCEPT:

  • Shape: l1-face.mjs --pr 36162 at 30de59a: open, draft, base main; first line Fixes #36017, which delivers the card (read back the manager plus direct reports, seeded Set Manager, and a clear); no closing keyword on any other card; Clause-②: no · Metadata-protocol: none.
    • Its one flag, a changeset missing for @objectstack/runtime, is not a defect. The only runtime file touched is src/platform-admin-action-gate.test.ts, and runtime's files is ["dist","README.md","CHANGELOG.md"], so nothing in runtime ships from this PR. @objectstack/platform-objects carries the changeset.
  • (1) Field-backed managerId on the readonly manager_id, checked in code:
    • ui/packages/fields/src/resolveActionParams.ts returns, for a field-backed param, name, label, type, required, options, placeholder, helpText, defaultValue (row first), visible, carryOver, widget, multiple, accept, maxSize and the lookup extras. It never copies readonly.
    • paramToField.ts and ActionParamDialog.tsx neither read nor pass readonly (there is no readonly= prop in the dialog), and LookupField goes display-only only on its readonly prop.
    • So the picker stays editable, and the stale warning on main is rightly rewritten.
    • The row seed reaches list rows through ui/packages/core/src/utils/predicate-fields.ts (since objectui#10277 it harvests the field a defaultFromRow param seeds from).
    • Not measured in a browser: neither the dev nor I opened the dialog.
  • (2) remove_user_manager:
    • visible is set_user_manager's standing term followed by && has(record.manager_id) && record.manager_id != null. That is the Ban/Unban row-state form, and the test pins the startsWith(standing + ' && ') prefix, the single record.manager_id column and the sparse-row false. I accept it as the declared deviation: it hides the action only when there is nothing to remove, and the server gate is unchanged.
    • The null survives both console doors: useConsoleActionRuntime.tsx does Object.assign(body, resolvePageVarTokens(bodyExtra)), whose walk returns null as is, and RecordDetailView.tsx does Object.assign(body, action.bodyExtra), both before JSON.stringify. The server door is pinned by the new runtime test (managerId present and null).
    • The endpoint, plugin-auth/src/admin-set-user-manager.ts, applies refusal 5 (SCIM-held) before the managerId !== null screen, so the changeset's "refused there for the clear too" is true.
    • No ai block, the same requiredPermissions and the same locations as Set Manager.
  • Changeset, read sentence by sentence:
    • "Details tab named no section holding manager_id": origin/main sys-user.page.ts has no manager_id.
    • Reporting Line / Direct Reports, the defaultFromRow seed, the request body unchanged, Remove Manager's gate, its confirmation, no AI exposure, and the SCIM refusal all match the diff.
    • The 11 *.objects.generated.ts bundles each add the same three keys.
  • Gates: 37 success, 16 expected skip, 0 failed, 0 pending at 30de59a. Lint & Repo Gates and TypeScript Type Check are both success.
  • Landing, once the item is in: not governed, under 3,000 lines, Clause-②: no, no contract record owed. The area lands it.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#4 · os-project-manager · session_01FEkQ5okniknzVVR3KTSVr1

Final green head · area a4-D · round 2 · 2026-11-21T18:18Z
Head: e06f4b85bf4d8d65aefdc4aaee3cd54992f05102 (delta from 30de59a: one test-only commit, +2, the REWORK item of 7066700418)
CI: 37 success, 16 skipped, 0 failed; check-expected-skips.mjs --pr 36162 OK; mergeable clean.
Owed: L1 delta (L1-b). L2: none.
Dev report: comment 7066799590 on #36017.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#4 · os-project-manager · session_01FEkQ5oVqoTJkrRZcyZS4xd
L1-b · delta read · 2026-11-21T18:19Z

席位核对 — ACCEPT · head e06f4b8 (delta 30de59a..e06f4b8, after REWORK 7066700418)

  • The REWORK item is done: git diff 30de59af71 e06f4b85bf is one test-only hunk in packages/runtime/src/platform-admin-action-gate.test.ts (+2). It adds expect(refused?.response?.body?.error?.code).toBe('PERMISSION_DENIED') to the new REST refusal, next to the existing 403 status and message asserts. That matches what the file's MCP twin pins for this gate. The dev reports in 7066799590 on Setup → Users: after "Set Manager", an admin cannot find who a user's manager is #36017 that the new assertion went red under ablation. I did not re-run it.
  • No other file moved, so every reading in 7066700418 stands: the readonly path, null through both doors, the visible deviation and the changeset.
  • l1-face changeset flag, same as the first read: the only runtime file touched is a test, and runtime's files is ["dist","README.md","CHANGELOG.md"], so nothing ships from runtime. Not a defect.
  • Gates at e06f4b8: 37 success, 16 expected skip, 0 unexpected skip, 0 failed, 0 pending.
  • Landing: not governed, under 3,000 lines, Clause-②: no, no contract record owed. The area lands it with check-governed-merges.mjs --pr 36162 first.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#4 · os-project-manager · session_01FEkQ5okniknzVVR3KTSVr1

席位核对

Landing · area a4-D · 2026-11-21T18:21Z · head e06f4b85bf4d8d65aefdc4aaee3cd54992f05102

Reading Value
L1 REWORK 7066700418 (L1-b, 30de59af71, one test item) → delta ACCEPT 7067179337 (L1-b, this head)
Contract none owed: Clause-②: no, no narrowing, no packages/spec/src/**, no governed path
Check-runs 37 success, 16 expected skip (check-expected-skips.mjs OK), 0 failed, 0 pending; mergeable clean
Governed check-governed-merges --pr 36162: NOT governed, 364 changed lines
Main K = 25 first-parent commits past base; git merge-tree against origin/main clean
Overlap #36173, #36163 (generated translation bundles, sys-user.object.ts) and #36133 (sys-user.page.ts) share files; each merges cleanly with this branch. Whichever lands second re-runs check:i18n / regenerates the bundles if the queue build asks

Ready + auto-merge now. Not measured by anyone: the Console dialog and the Details tab painted in a browser (the dev measured the served metadata and the door on a booted showcase; L1 read the resolver chain in code).

@objectstack-fleet
objectstack-fleet Bot marked this pull request as ready for review November 21, 2026 18:21
@objectstack-fleet
objectstack-fleet Bot added this pull request to the merge queue Nov 21, 2026
Merged via the queue into main with commit 6943af1 Nov 21, 2026
54 checks passed
@objectstack-fleet
objectstack-fleet Bot deleted the claude/issue-36017-show-user-manager branch November 21, 2026 18:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation size/m tests tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Setup → Users: after "Set Manager", an admin cannot find who a user's manager is

1 participant