Repository navigation
Commit d0a1361
fix(plugin-approvals): a new delegation starts with the Delegator set to you, and its help says why (#25420)
<!-- claude-projects-attribution: {"github_login":"os-sales"} -->
_Requested by **Sales** · [project
thread](https://claude.ai/code/project/chan_01D5bWFY3rFzgJcytD5gD4Uu?thread=cmsg_01D5bWFY3rFzgJcytD5gD4UuACdPWFJTLDcTrByFCHLzqb)_
Fixes #25342
Clause-②: no
Metadata-protocol: none
## What
Setup → Delegations (OOO): the Delegator of `sys_approval_delegation`
only ever offers the signed-in user, because `bindDelegationWriteGuard`
admits nobody else. The field still opened at "Select…", and a search
for a colleague answered "No options found" with no reason.
- `delegator_id` now declares `defaultValue: 'current_user'`. A new
delegation starts with its one admissible Delegator filled in.
- The field's help now says why: "The user going out of office. You can
delegate only your own approvals, so this is always you: it starts as
you and offers no one else. Their individually-routed approver slots are
rerouted while active."
- The `lookupFilters`, the write guard and the approval-service filter
are unchanged. `organization_id` is not touched; queued #25280 edits
that field's help.
## Why this spelling
I checked how the platform defaults a person field to the current user,
on `origin/main` `830a63a680`:
- `packages/spec/src/data/field.zod.ts` `defaultValue` says
`current_user` is legal "on `user` or `lookup` with `reference:
'sys_user'` only". The spec's token table is `defaultValueTokenIssue` in
`packages/spec/src/data/default-value-shape.ts`, and the constant is
`DEFAULT_VALUE_TOKEN_CURRENT_USER` in `default-value-tokens.ts`.
- The engine resolves it at insert time to the acting user's id:
`packages/objectql/src/engine.ts`, the `isCurrentUserDefaultToken`
branch of the field-default pass. With no authenticated user it leaves
the field unset.
- The one in-repo declaration is
`examples/app-showcase/src/data/objects/field-zoo.object.ts` `f_owner`
(`Field.user({ defaultValue: 'current_user' })`). No other platform
object defaults a lookup to the current user, so this is the first such
platform field. It uses the spelling the spec, the engine and the docs
(`content/docs/data-modeling/field-types.mdx`) all name.
`packages/spec` is not edited.
## Translations
- `en` was regenerated with `node scripts/check-i18n-bundles.mjs
--write`.
- `es-ES` and `ja-JP` were byte copies of the old English help. They now
carry translations, and the next extract dropped their two
`source-hashes` entries.
- `zh-CN` already had a translated help, so I updated it to the new
meaning too. It has no hash entry, so nothing would have flagged it as
stale.
## Tests
`packages/plugins/plugin-approvals/src/sys-approval-delegation-delegator-picker.test.ts`
keeps every existing pin. It gains one for the default: the declaration
and the registered body carry `DEFAULT_VALUE_TOKEN_CURRENT_USER`, and a
full `FieldSchema.safeParse` of the field is green, so the spec admits
the token on this lookup.
- `pnpm --filter @objectstack/plugin-approvals test`: Test Files 94
passed (94), Tests 1215 passed (1215).
- `pnpm --filter @objectstack/plugin-approvals typecheck`: exit 0.
`check:test-typecheck` reports OK.
- Ablation: deleting `defaultValue: 'current_user',`
(`scripts/ablation-replace.mjs`, anchor x1 -> x0) turned the new pin red
(`expected undefined to be 'current_user'`, 1 failed | 9 passed). The
file was restored to its HEAD blob and `git diff HEAD` was empty. The
test imports the object from `src/`, so no build was needed. My first
attempt was a refused anchor miss, so nothing ran on it.
- Derived gate families: run locally on this head. The PR's check-runs
carry the full set.
## Acceptance notes
- **The console's form prefill is NOT MEASURED.** objectui answers 403
from this container, so I could not read how its create form treats a
`current_user` default. The server side is pinned. If the console does
not prefill from this token, that gap belongs to objectui and would hit
the showcase `f_owner` field too. It is not a reason to change the
spelling here.
- Server-side writes behave as before. The engine default and the write
guard's omitted-delegator stamp both name the acting user. A system
write with no user still leaves the field unset, so `required` refuses
it, and the existing pin holds that.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
https://claude.ai/code/session_016g7nYP9wdNx1GDa5XDr7Uy
---------
Co-authored-by: Claude <noreply@anthropic.com>1 parent 77392e9 commit d0a1361
9 files changed
Lines changed: 47 additions & 10 deletions
File tree
- .changeset
- packages/plugins/plugin-approvals/src
- translations
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
27 | | - | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
28 | 31 | | |
29 | 32 | | |
30 | 33 | | |
31 | 34 | | |
32 | 35 | | |
33 | | - | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
34 | 42 | | |
35 | 43 | | |
36 | 44 | | |
| |||
121 | 129 | | |
122 | 130 | | |
123 | 131 | | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
124 | 143 | | |
125 | 144 | | |
126 | 145 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
94 | 94 | | |
95 | 95 | | |
96 | 96 | | |
97 | | - | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
98 | 102 | | |
99 | 103 | | |
100 | 104 | | |
| 105 | + | |
101 | 106 | | |
102 | 107 | | |
103 | | - | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
104 | 111 | | |
105 | 112 | | |
106 | 113 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
354 | 354 | | |
355 | 355 | | |
356 | 356 | | |
357 | | - | |
| 357 | + | |
358 | 358 | | |
359 | 359 | | |
360 | 360 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
354 | 354 | | |
355 | 355 | | |
356 | 356 | | |
357 | | - | |
| 357 | + | |
358 | 358 | | |
359 | 359 | | |
360 | 360 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
29 | | - | |
30 | 29 | | |
31 | 30 | | |
32 | 31 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
354 | 354 | | |
355 | 355 | | |
356 | 356 | | |
357 | | - | |
| 357 | + | |
358 | 358 | | |
359 | 359 | | |
360 | 360 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
28 | | - | |
29 | 28 | | |
30 | 29 | | |
31 | 30 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
354 | 354 | | |
355 | 355 | | |
356 | 356 | | |
357 | | - | |
| 357 | + | |
358 | 358 | | |
359 | 359 | | |
360 | 360 | | |
| |||
0 commit comments