Repository navigation
Commit 04f36b6
feat(service-automation): a record-triggered flow's notification links to the record that started the run when it names no link (#30252)
<!-- claude-projects-attribution: {"github_login":"os-bill"} -->
_Requested by **Bill** · [project
thread](https://claude.ai/code/project/chan_016iMXWSZDzqWRWvWzdNo8wg?thread=cmsg_016iMXWSZDzqWRWvWzdNo8wgM2GxWhdgy4dyjBtN2tYY9u)_
domain:server#4 · os-bill · session_01Utp6CZMkHvuDeVYgTD73qF
## 维护者速读
- **改了什么:** 由记录触发的流程里,通知节点没写 `sourceObject`/`sourceId`/`actionUrl`
时,通知默认链到触发这次运行的那条记录;点开通知直接进记录页。
- **为什么改:** 技术员收到「工单分配给你」的通知,点开却落在通知列表;作者照最自然的写法(收件人、标题、正文)写,`os
validate` 也通过,链接却是空的。卡 #30121「第一组:会卡住人或误导人」。
- **风险与回滚:** 只在三项都没写、且运行确有触发记录时生效;显式的一对或 `actionUrl`
照旧优先,半对照旧丢弃,定时/API/无记录的手动运行不变,删除事件不链(记录已不在)。回滚即撤本 PR。
- **先看:**
`packages/services/service-automation/src/builtin/notify-node.ts` 的
`defaultClickThroughOf` 与调用处,再看 `notify-node.test.ts` 末尾新的 describe。
- **两分钟验证:** `pnpm --filter @objectstack/service-automation exec vitest
run --maxWorkers=2 src/builtin/notify-node.test.ts`,预期 23 条全绿。
- **需要你做的:** 无,席位落地。
Fixes #30121
Clause-②: no — no accepted key, value or exported type changes;
`sourceObject` / `sourceId` / `actionUrl` keep their meaning when
written, and no option or type member was added to reach the trigger
record (the node already reads it through `triggerRecordOf`).
Metadata-protocol: semantic
Skills-docs: follow-up owed — skills/objectstack-automation/SKILL.md
(the notify example's `click-through: a PAIR, else dropped` line),
content/docs/automation/flows.mdx (the notify `sourceId` paragraph),
packages/spec/src/automation/io-node-config.zod.ts (the `sourceObject` /
`sourceId` describes, which feed
content/docs/references/automation/io-node-config.mdx). The skill line
is a governed (Tier H) edit and the spec describe is out of this order's
scope, so neither rides here; the seat files the card.
## What changes
**`@objectstack/service-automation` — the `notify` node**
(`src/builtin/notify-node.ts`):
- New `defaultClickThroughOf(cfg, context, trigger)`. When the node
writes none of `sourceObject`, `sourceId` and `actionUrl`, the
click-through record is the run's trigger record, read through the
existing `triggerRecordOf(context)`: the same reading `recipients: {
emailField }` and the organization fallback already use. The messaging
service then stores it as `sys_notification.source_object` / `source_id`
and synthesizes `/OBJECT/ID`, exactly as for an authored pair.
- What counts as a trigger record, measured on `origin/main` at the
run-starting doors:
- record change (`trigger-record-change`): `object` + the row,
`record.id` present. **Defaults.**
- time-relative sweep (`trigger-schedule` `time-relative-trigger.ts`):
`object: desc.object`, `record: row`. That object's row is the record
the run is about, so it **defaults**.
- action on a record (`runtime` `action-execution.ts`): `object` +
`record` with the requested `recordId` stamped. **Defaults.**
- schedule tick, inbound API post (`trigger-api`: `record: payload` with
no `object`), manual REST start (`object` but no `record`): no trigger
record. **Unchanged.**
- Delete events (`beforeDelete`, `afterDelete`) are not defaulted: the
record is gone once the write lands, and this node already drops a
half-written pair so the inbox never renders a dead link. An authored
pair on a delete flow is still honoured.
- A half-written pair keeps today's behaviour: it is dropped and nothing
is defaulted in its place, because the author did write a link.
- An `actionUrl` written alone keeps today's behaviour too: the URL is
the link and no `source` is defaulted beside it, per the card's "an
explicit `actionUrl` or pair still wins".
- The organization fallback (#23284) asked `[source, trigger]`; a
defaulted `source` is the trigger record itself, so the second candidate
is skipped when it is the same object (no second `findOne`). The
organization it resolves is unchanged.
- The Studio form help for `sourceObject`, `sourceId` and `actionUrl`
(the node descriptor's `configSchema`) says the default.
## Tests
`src/builtin/notify-node.test.ts`, one new top-level `describe` in the
existing harness, six pins:
1. record-triggered notify, no link written ⇒ `source` is `{ object:
'repair_ticket', id: 't_7' }`, no `url`;
2. explicit pair wins over the trigger record;
3. explicit `actionUrl` alone: `url` as written, no `source` defaulted;
4. half-written pair (`sourceObject` only): still dropped;
5. run with no trigger record (`object`, no `record`): no `source`;
6. `afterDelete`: no `source`.
<details><summary>Local runs (head after the final commit is in the
report)</summary>
- `pnpm --filter @objectstack/service-automation exec vitest run
--maxWorkers=2 src/builtin/notify-node.test.ts`: Test Files 1 passed,
Tests 23 passed (17 before + 6).
- `pnpm --filter @objectstack/service-automation test` (under
`os-verify-lock.sh`): Test Files 263 passed (263), Tests 3407 passed
(3407), lock VERDICT command-exit 0.
- `pnpm --filter @objectstack/service-automation typecheck`: exit 0
(test layer included, `check:test-typecheck` OK, 0 debt).
</details>
<details><summary>Ablation (one, on the behaviour the pins
hold)</summary>
`node scripts/ablation-replace.mjs` on `notify-node.ts`, anchor `return
trigger;` (the default's answer) replaced by `return trigger &&
undefined; // ABLATED_30121`: anchor x1 to x0, replacement x0 to x1,
blob 94746f6 to 381704ef410f. Run: Tests 1 failed, 22 passed; the
one red is pin 1, "links a record-triggered notify that names no source
to the trigger record". Restored: blob equals HEAD (94746f6), `git
diff HEAD` empty. The test imports the executor from `src`, so no build
sat between the mutation and the run.
A first attempt used a bare identifier as the marker, which threw a
ReferenceError and turned eight unrelated tests red; that run was
discarded as a malformed mutation, not counted.
</details>
## Acceptance notes
- The spec's own describes for `sourceObject` / `sourceId`
(`packages/spec/src/automation/io-node-config.zod.ts`) still say "Only
takes effect together with …", which stays true for an authored pair but
does not mention the default. Out of this order's scope
(`packages/spec/src/**`); listed under `Skills-docs:` above.
- A flow started by an action whose caller could not read the row
(`recordLoadDenied: true`) still carries the requested id, so its
notification links to that id, as the authored `sourceId: record.id`
would. The record page applies the recipient's own access when opened.
## Verification
Gate list derived with `node scripts/pm/dispatch-gates.mjs --commands
--repo objectstack-ai/objectstack`; each command's exit code was
recorded before any pipe and reconciled with `--ran`. Readings are in
the os-dev-report comment on #30121. `origin/main` was merged once
before opening (no incoming commit touched `service-automation` or
`packages/spec`).
---
_Generated by [Claude
Code](https://claude.ai/code/session_01Utp6CZ1tD2uZm21w4Bj1xs)_
---------
Co-authored-by: Claude <noreply@anthropic.com>1 parent eb6199b commit 04f36b6
3 files changed
Lines changed: 139 additions & 7 deletions
File tree
- .changeset
- packages/services/service-automation/src/builtin
| 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 | |
|---|---|---|---|
| |||
393 | 393 | | |
394 | 394 | | |
395 | 395 | | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
106 | 106 | | |
107 | 107 | | |
108 | 108 | | |
109 | | - | |
110 | | - | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
111 | 113 | | |
112 | 114 | | |
113 | 115 | | |
| |||
156 | 158 | | |
157 | 159 | | |
158 | 160 | | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
159 | 190 | | |
160 | 191 | | |
161 | 192 | | |
| |||
851 | 882 | | |
852 | 883 | | |
853 | 884 | | |
854 | | - | |
| 885 | + | |
855 | 886 | | |
856 | 887 | | |
857 | 888 | | |
858 | | - | |
| 889 | + | |
859 | 890 | | |
860 | 891 | | |
861 | 892 | | |
| |||
868 | 899 | | |
869 | 900 | | |
870 | 901 | | |
871 | | - | |
| 902 | + | |
872 | 903 | | |
873 | 904 | | |
874 | 905 | | |
| |||
985 | 1016 | | |
986 | 1017 | | |
987 | 1018 | | |
| 1019 | + | |
| 1020 | + | |
| 1021 | + | |
988 | 1022 | | |
989 | 1023 | | |
990 | | - | |
| 1024 | + | |
991 | 1025 | | |
992 | 1026 | | |
993 | 1027 | | |
| |||
1089 | 1123 | | |
1090 | 1124 | | |
1091 | 1125 | | |
| 1126 | + | |
| 1127 | + | |
1092 | 1128 | | |
1093 | 1129 | | |
1094 | | - | |
| 1130 | + | |
1095 | 1131 | | |
1096 | 1132 | | |
1097 | 1133 | | |
| |||
0 commit comments