You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 84d209d
Browse filesBrowse the repository at this point in the historyBrowse files
feat(console): the chat's draft review card publishes a draft, pinned to the version the turn saved (#39014)
<!-- claude-projects-attribution: {"github_login":"os-support-ai"} -->
_Requested by **Yibo Wang** · [project
thread](https://claude.ai/code/project/chan_01BVUyyPie8gHwoPM18iABwB?thread=cmsg_01BVUyyPie8gHwoPM18iABwBCBEbFaYjr1yVnYsDrfd5rS)_Fixes#38983Fixes#39015
Clause-②: yes (widening)
Metadata-protocol: added
Skills-docs: none — the row is a stream part a host writes for the chat,
which no skill teaches; the docs page
`content/docs/frontend/plugins/plugin-chatbot.mdx` is updated here
## 维护者速读
-
用户能看到什么变化:助手搭建完后,对话里的草稿审阅卡上每个草稿多了「发布」按钮,人点一下就发布这一个草稿,结果(已发布、被拒及原因、本轮之后有改动未发布)留在卡上。
- 为什么做:云端专题「助手搭建应用」第二阶段,人不用再跳到应用搭建里去发布。
- 出错会怎样:只有带版本号、判定可发布的草稿能点;草稿在本轮之后被改过会被拒、什么都不发布;AI
仍然不能自己发布。版本号要云端写进审阅卡,云端补上之前按钮是灰的。
- 要你做什么:无。
## What changes
- **Spec** (`packages/spec/src/ai/draft-review.zod.ts`):
`DraftReviewItemSchema` gains the optional `version` (non-empty string),
the draft's version token as the turn's last save of it wrote it. The
docblock's "What the card does not do / Nothing is published or
discarded from the chat" flips to "What the card publishes": one draft
per click, as the person, pinned through `draftVersion`; nothing
discarded. Reference page regenerated.
- **Card** (`ui/packages/plugin-chatbot/src/chat/DraftReviewCard.tsx`):
with a host `onPublishDraft`, each row carries a Publish button. Enabled
only on a row with a `version` and a `publishable` verdict; otherwise
disabled with the reason in its title and accessible name (`noVersion`,
`withheld`, `refusals`). The row keeps the click's result: `published`
(button gone), `conflict` (draft changed since the turn, button gone),
`refused` with the platform's code and sentence (button stays for
another try). A host that throws is shown as a refusal. With no host
prop the card is unchanged (no buttons). `ChatbotEnhanced` passes the
prop through; its comment line saying nothing is published here flips.
- **Host**
(`ui/packages/app-shell/src/console/ai/draftReviewPublish.ts`, new):
`publishReviewedDraft` reuses `publishDetailSave` (the item page's
pinned item publish) with `packageId` = the row's package,
`draftVersion` = the row's version and `hadDraft` = true, so a refusal
never takes the assistant's draft back. 409 `METADATA_CONFLICT` maps to
`conflict`; anything else to `refused` with the error's code and
message. A row with no version is never sent. `ChatPane` wires it in
(one import, one hook call, one prop; the file stays at 1,000 lines).
- **i18n**: 12 `chatbot.draftReview.*` keys in all 11 locale packs
(zh-Hant regenerated).
- **#39015, folded in** (same file, describe-only): `verdictWithheld`'s
`.describe()` and the docblock line now also cover a draft the door left
unjudged under a bound such as `MAX_RECORDS_EXCEEDED`; shape unchanged.
- **Docs**: `content/docs/frontend/plugins/plugin-chatbot.mdx` § Draft
review card teaches `onPublishDraft` and drops "no publish control".
- **Changeset**: `minor` on spec (the `Check Changeset` gate reads
`packages/spec/authorable-surface/ai.json` gaining
`ai/DraftReviewItem:version`, an authorable key added), patch on
plugin-chatbot, app-shell, i18n; says the "nothing is published from the
chat" contract changes.
Seat rulings carried (card thread order): optional version key, Clause-②
yes (widening); the protocol line moved from the agreed `none` to
`added` because the authorable-surface ratchet records
`DraftReviewItem`, and the gate refuses `none` on a moved shard; the
docblock and the ChatbotEnhanced line flip, the changeset says so; no
producer of the part lives in this repo (the cloud host fills it), so
this ships the key plus the button and Publish is disabled on a row with
no version. The cloud producer follow-up is the seat's to file. Discard
(optional on the card) is not built.
Risk-ranked first reads: `DraftReviewCard.tsx` `publishBlock` and
`publishControl` (what is clickable, what each result shows);
`draftReviewPublish.ts` (pin and conflict mapping); the spec docblock
flip.
## Tests
Run on 86fbd98 (objectstack-ai/objectstack, main 571b494 base); the
head now adds docs, the changeset and the #39015 wording only:
- `pnpm --dir ui exec vitest run
packages/plugin-chatbot/src/__tests__/DraftReviewCard-38048.test.tsx
packages/plugin-chatbot/src/__tests__/DraftReviewCard.i18n-38048.test.tsx
packages/app-shell/src/console/ai/draftReviewPublish-38983.test.ts`: 3
files, 22 tests passed.
- Card (new top-level describe in the card's harness file): publishes
the publishable versioned row through `onPublishDraft` and shows it
published; refused, withheld and unversioned rows are disabled with the
reason and never call the host; conflict shown, no second Publish;
`PERMISSION_DENIED` shown with code and sentence, Publish kept; a
throwing host shown as a refusal.
- Host (against the `draftPublishDoor` fake that enforces the draft
pin): the turn's draft goes live with `{ packageId, draftVersion }`; a
draft another writer changed is `conflict`, not live, kept, no reset; a
403 refusal carries code and message, no reset; no version, no publish
call.
- Ablation: dropping `draftVersion` from the host's publish turns 2 of 4
host tests red (the pin assertion and the conflict PIN); restored from
HEAD, tree clean.
- `pnpm --filter @objectstack/spec exec vitest run
src/ai/draft-review.test.ts`: 13 passed (new: version kept, optional,
empty and non-string refused with path).
- `pnpm --filter @object-ui/plugin-chatbot type-check` exit 0; `pnpm
--filter @object-ui/app-shell type-check` exit 0 (both incl.
tsconfig.test.json).
- `pnpm --filter @objectstack/spec check:generated`:
`content/docs/references/**` was stale, regenerated with `--fix`,
re-check green.
## Acceptance notes
- Acceptance 1–3 are pinned in this PR at the framework layer; they hold
end to end once the cloud host states each row's `version` in the
`data-draft-review` part. Until then every row's Publish is disabled
("Publish this draft in App Studio.").
- Acceptance 4's staging browser check is cloud's, recorded on
objectstack-ai/cloud#5304.
- The cloud remainder (the host fills each row's `version` from the save
receipt, plus the staging browser check) is asked of triage for a cloud
card: #36743 comment 7330317456. This PR completes the framework side.
- The eager en locale chunk budget (`check-eager-locale-catalogues` /
`check-eager-closure-budget`) needs a console build: NOT MEASURED
locally, read from CI.
## Verification
Two minutes: run the vitest line under Tests; the five
`objectstack#38983` cases in the card harness and four in
`draftReviewPublish-38983.test.ts` pass.
<details><summary>Derived gate families (local subset)</summary>
`node scripts/pm/dispatch-gates.mjs --commands` derived 112 commands on
86fbd98; run one by one, exit code captured before any pipe. Later
heads add only docs, the changeset and one `.describe()` wording (spec
rebuilt and `check:generated` re-run green on them).
- 108 of 112 exit 0.
- NOT MEASURED, exit 3 (prerequisite, not a finding):
`check-plugin-teardown-shape.mjs --self-test` (its fixture is pinned to
a commit this shallow clone cannot reach), `check:skill-examples` (needs
a `@objectstack/client-react` dist), `check:dual-build-cjs-loads` (needs
every package's dist).
- NOT MEASURED, exit 124: `check:type-check-debt` (its re-measure passed
the 300 s local cap).
- CI runs all four. Report: #38983 comment 7331415099.
</details>
🤖 Generated with [Claude Code](https://claude.com/claude-code)
https://claude.ai/code/session_01WGufziUBsnPje7KHsByhN5
---
_Generated by [Claude
Code](https://claude.ai/code/session_01WGufziUBsnPje7KHsByhN5)_
<!-- signed: repo:objectstack@os-support-ai · os-support-ai ·
session_01WGufziUBsnPje7KHsByhN5 -->
---------
Co-authored-by: Claude <noreply@anthropic.com>
feat(console): the chat's draft review card publishes a draft, pinned to the version the turn saved
9
+
10
+
Clause-②: yes (widening)
11
+
Metadata-protocol: added
12
+
13
+
Widened: `DraftReviewItemSchema` (`@objectstack/spec/ai`, the row of the `data-draft-review` stream part) gains the optional `version`, the draft's version token as the turn's last save of it wrote it (the save receipt's `version`). `DraftReviewCardProps` and `ChatbotEnhancedProps` gain the optional `onPublishDraft`, and `@object-ui/plugin-chatbot` exports the type `DraftReviewPublishResult`; the card's Publish strings are added to every shipped locale pack.
14
+
15
+
The contract that nothing is published from the chat changes. The review card under an ask turn's answer now carries a Publish button per draft: one click publishes that one draft as the signed-in person, through the item's own publish (`POST /meta/:type/:name/publish?package=`), with the row's `version` sent as the body's `draftVersion`. A draft changed after the turn saved it is refused `409 METADATA_CONFLICT`, nothing is published, and the row says the draft changed since the turn. Any other refusal (a member who may not publish gets `PERMISSION_DENIED`) is shown on the row with the platform's code and sentence. Publish is offered only on a row that carries a `version` and whose verdict is `publishable`; a refused, withheld or unversioned row shows it disabled with the reason and is published in Studio through the review links, as before. The agent is given no publish: the click is always the person's. Nothing is discarded from the chat.
16
+
17
+
`verdictWithheld`'s description now also covers a draft the door left unjudged under a bound such as `MAX_RECORDS_EXCEEDED`, not only a verdict the person may not read; its shape is unchanged.
18
+
19
+
A host that fills the `data-draft-review` part must state each row's `version` for the button to be enabled; a part without it draws the card as before, with Publish disabled.
20
+
21
+
Why the protocol line reads added: `DraftReviewItem` is on the authorable surface the ratchet records (`packages/spec/authorable-surface/ai.json`), and `version` is a key that enters it. Nothing a released version accepts is refused now.
@@ -77,10 +91,11 @@ const result = DraftReviewItemSchema.parse(data);
77
91
|**package**|`string`| ✅ | The package the draft was saved into |
78
92
|**label**|`string`| optional | The draft's display label, when it has one |
79
93
|**verdict**|`{ publishable: boolean; refusals: object[]; advisories: object[] } \| null`| ✅ | The door's `list_drafts` verdict, read as the person who asked; `null` when none was read (see `verdictWithheld` and `verdictError`) |
80
-
|**verdictWithheld**|`{ code: string; message: string; status: integer }`| optional | Why the person may not read a verdict, when `verdict` is `null` for that reason |
94
+
|**verdictWithheld**|`{ code: string; message: string; status: integer }`| optional | Why the door gave no verdict, when `verdict` is `null` for that reason: the person may not read it, or the door left the draft unjudged under a bound such as `MAX_RECORDS_EXCEEDED`; the `message` says which|
81
95
|**verdictError**|`{ code: string; message: string; status: integer }`| optional | That reading the verdict failed, when `verdict` is `null` for that reason |
82
96
|**verdictRead**|`Enum<'turn-end' \| 'save'>`| ✅ | When the verdict was read: `turn-end`, after the turn's last save, or `save`, by the save that wrote this draft |
|**version**|`string`| optional | The draft's version token as the turn's last save of it wrote it (the save receipt's `version`). The card's Publish sends it as the publish body's `draftVersion`, so a draft changed since is refused 409 `METADATA_CONFLICT`, never published; absent, the row offers no Publish in the chat |
84
99
85
100
### Nested Shape: `DraftReviewItem.verdict`
86
101
@@ -146,10 +161,11 @@ const result = DraftReviewItemSchema.parse(data);
146
161
|**package**|`string`| ✅ | The package the draft was saved into |
147
162
|**label**|`string`| optional | The draft's display label, when it has one |
148
163
|**verdict**|`{ publishable: boolean; refusals: object[]; advisories: object[] } \| null`| ✅ | The door's `list_drafts` verdict, read as the person who asked; `null` when none was read (see `verdictWithheld` and `verdictError`) |
149
-
|**verdictWithheld**|`{ code: string; message: string; status: integer }`| optional | Why the person may not read a verdict, when `verdict` is `null` for that reason |
164
+
|**verdictWithheld**|`{ code: string; message: string; status: integer }`| optional | Why the door gave no verdict, when `verdict` is `null` for that reason: the person may not read it, or the door left the draft unjudged under a bound such as `MAX_RECORDS_EXCEEDED`; the `message` says which|
150
165
|**verdictError**|`{ code: string; message: string; status: integer }`| optional | That reading the verdict failed, when `verdict` is `null` for that reason |
151
166
|**verdictRead**|`Enum<'turn-end' \| 'save'>`| ✅ | When the verdict was read: `turn-end`, after the turn's last save, or `save`, by the save that wrote this draft |
|**version**|`string`| optional | The draft's version token as the turn's last save of it wrote it (the save receipt's `version`). The card's Publish sends it as the publish body's `draftVersion`, so a draft changed since is refused 409 `METADATA_CONFLICT`, never published; absent, the row offers no Publish in the chat |
'The door\'s `list_drafts` verdict, read as the person who asked; `null` when none was read '
134
148
+'(see `verdictWithheld` and `verdictError`)',
135
149
),
136
-
verdictWithheld: DraftReviewVerdictRefusalSchema.optional().describe('Why the person may not read a verdict, when `verdict` is `null` for that reason'),
0 commit comments