Repository navigation
Commit 5f741ed
fix(app-shell): AI-draft notice and discard on the Hooks tab, paired actions and OWD rows (#38285)
<!-- claude-projects-attribution: {"github_login":"os-tesla"} -->
_Requested by **Tesla** · [project
thread](https://claude.ai/code/project/chan_01AXsQkLFKRdQCqQ3RTr6Jao?thread=cmsg_01AXsQkLFKRdQCqQ3RTr6Jao153cRYFjsg9HJ2VwLVqVbD)_
Fixes #36660
repo:objectstack#3 · os-tesla · session_01L9qibxGxp6swERUK2T9NML
Clause-②: no
Metadata-protocol: none
## 维护者速读
- 在对象设计器的「钩子」页、只读基础对象「动作」页里的配套包动作、以及共享默认值总览的每一行上,如果 AI
助手留下了未发布的改动,现在会显示一行提示,说明保存会让 AI 的改动一起生效,并给一个「放弃 AI
的改动」按钮;以前保存会悄悄把它们一起发布。
- 属于「AI 改动要让人看见再生效」这条线:权限集和从左侧菜单打开的钩子、动作已经有这行提示,这次补齐剩下的三处。
- 只在草稿确实来自 AI
助手时才显示,人自己的草稿不受影响;放弃只丢这一项(共享默认值这一行是整个对象)的草稿,有没保存的编辑时会先确认。如果提示出现得不对,只是多一行文字和按钮,可以直接撤回。
- 无
## What changes
- **Object designer, Hooks tab** (`objectHooksBuffer.ts`,
`ObjectHooksPanel.tsx`):
- The buffer's load records which hooks have a pending draft whose
provenance (`readDraftChanges`) names the AI assistant
(`isAgentDraftSurface`: copilot or MCP). The set clears on an object
switch and on a successful save.
- The open hook shows `StudioAiDraftNotice` when its draft is the AI's
and the hook is not a new one. The notice's discard calls the buffer's
new `discardAiDraft`.
- `discardAiDraft` asks `engine.studio.aiDraft.discardConfirmUnsaved`
only when the hook holds unsaved edits. It then calls
`client.reset('hook', name, { state: 'draft', packageId })`, the hook's
own package, re-reads the list and emits the metadata refresh. A failure
reads `engine.studio.aiDraft.discardFailed`.
- **Paired package's actions on a read-only base object**
(`pairObjectActions.ts`, `ObjectActionsPanel.tsx`):
- A draft row whose provenance names the AI assistant carries `aiDraft`.
A successful save, and a discard, put the row back to its live form.
- The selected row shows the notice above the inspector. Discard is
offered only where the row is editable.
- `discardAiDraft(name)` asks only when that row holds an unsaved edit.
It resets at the package the ensure door answers (`pairForWrite()`),
never a hand-built `<base>.custom` name, then reloads.
- **Organization-wide defaults overview**
(`PackageOwdOverviewPanel.tsx`), seat ruling Q1 = A:
- Each row reads its object's draft provenance. When the AI assistant
wrote it, the row shows the notice with the OWD sentence,
`engine.studio.owd.aiDraftNotice`: the whole object has the AI's
unpublished changes, and saving this row makes all of them live. The
plain "unpublished" chip is not shown beside it.
- Discard drops that object's whole draft at the package
(`client.reset('object', name, { state: 'draft', packageId })`). It asks
`engine.studio.owd.aiDraftDiscardConfirmUnsaved` only when that row
holds an unsaved edit. Other rows' unsaved edits are kept across the
re-read.
- `StudioAiDraftNotice.tsx`: an optional `text` prop, for a page that
names what the draft covers. Without it the item sentence shows, as
before.
- i18n (`studio` namespace, en + zh): the two OWD keys above. Changeset
`36660-owd-ai-draft-notice.md`: `@object-ui/i18n` patch.
`@object-ui/app-shell` is private.
- The hook list rows get no AI marker (seat ruling).
## Tests
Three new files, 19 cases. Each covers the AI line for copilot and for
MCP, no line for a person's draft or for a draft read with no
provenance, discard with nothing unsaved (no confirm, one reset at the
right package), and discard over an unsaved edit both declined and
confirmed.
- `ObjectHooksPanel.aiDraftNotice-36660.test.tsx` (7): through the Hooks
tab host and the top bar's Save. Save publishes the AI version and the
line goes away.
- `DataPillar.pairActionsAiDraft-36660.test.tsx` (6): a read-only base
object with a paired package. The reset names the door's pair.
- `PackageOwdOverviewPanel.aiDraftNotice-36660.test.tsx` (6): the row's
OWD sentence, the whole object's reset, and another row's unsaved edit
surviving a discard.
## Acceptance notes
- **Premise corrected at the claim:** the permission set and the hook
and action opened from the left menu already carry the notice (#37089,
#36902). This PR covers the three surfaces left.
- **Out of scope, for the seat to decide on filing:** for an item the AI
created and never published, the notice's discard tooltip reads "Drop
this item’s unpublished draft and go back to the live version", while
the discard removes the item. Seat ruling Q2: not in this card.
- The local test run was narrowed to the files these changes reach
(below). CI runs the whole app-shell suite.
- The browser reading used a writable package made for the run, since
the showcase package is managed (its writes answer `ITEM_LOCKED`). The
HTTP doors refuse a copilot surface, so the draft's provenance was
stamped as copilot in the stored draft row, and the served read
confirmed `draftChanges[].by = copilot`.
## Verification
<details><summary>Failing first, then green</summary>
- On the base sources with the new tests: 15 failed, 4 passed. The 4 are
the person's-draft and no-provenance controls. Failures: `Unable to find
… studio-ai-draft-discard` ×9, `studio-ai-draft-notice` ×6.
- With the change: 3 files, 19/19 passed.
</details>
<details><summary>Ablation</summary>
Two parts removed on disk and restored (blob equal to HEAD afterwards):
the OWD put-back of other rows' edits, and the hooks agent-surface check
(any draft counts). 3 failed, 10 passed: OWD "another row keeps its
edit", and hooks "a person's own pending draft" and "no provenance".
</details>
<details><summary>Wider runs</summary>
- Affected test files: 328/328 files, 2574/2574 tests.
- `@object-ui/app-shell` `tsc --noEmit` exit 0, `tsc -p
tsconfig.test.json` exit 0. ESLint on the changed files: 0 errors, 5
warnings that were already there.
- Derived gates at 4fd9904: 38 of 38 run, all exit 0, `dispatch-gates
--ran` accounted. `pnpm --dir ui exec vitest run scripts/`: 172 files
passed, 2 skipped.
- `overlap-check`: clean against `origin/main` and #38204 (shares the
studio i18n files).
</details>
<details><summary>Browser reading, real console build</summary>
Vite console against a showcase backend, signed in, Studio → package →
organization-wide defaults. Two objects in the package. The one with a
copilot-stamped draft shows under its name: "This object has unpublished
changes from the AI assistant. Saving this row makes all of them live
too." with "Discard the AI’s changes" (1 line, 1 button). The other
object's row shows no line.
</details>
---
_Generated by [Claude
Code](https://claude.ai/code/session_01L9qibxGxp6swERUK2T9NML)_
🤖 Generated with [Claude Code](https://claude.com/claude-code)
https://claude.ai/code/session_01L9qibxGxp6swERUK2T9NML
---------
Co-authored-by: Claude <noreply@anthropic.com>1 parent 4ebe9a1 commit 5f741ed
12 files changed
Lines changed: 992 additions & 13 deletions
File tree
- .changeset
- ui/packages
- app-shell/src/views/studio-design
- i18n/src/namespaces/studio
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 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 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
97 | 97 | | |
98 | 98 | | |
99 | 99 | | |
| 100 | + | |
100 | 101 | | |
101 | 102 | | |
102 | 103 | | |
| |||
160 | 161 | | |
161 | 162 | | |
162 | 163 | | |
| 164 | + | |
| 165 | + | |
163 | 166 | | |
164 | 167 | | |
165 | 168 | | |
| |||
820 | 823 | | |
821 | 824 | | |
822 | 825 | | |
| 826 | + | |
| 827 | + | |
| 828 | + | |
| 829 | + | |
| 830 | + | |
| 831 | + | |
| 832 | + | |
| 833 | + | |
| 834 | + | |
| 835 | + | |
| 836 | + | |
823 | 837 | | |
824 | 838 | | |
825 | 839 | | |
| |||
0 commit comments