Repository navigation
feat(studio): the Delete package dialog states what goes (objects with row counts, items by type, permanent drop) - #31193
Merged
Conversation
The dialog lists each object the package holds with the rows the data list counts, every other published item counted by type and the pending drafts, read from the package export door when it opens. Choosing to drop the data adds a line that the tables are dropped permanently and skip the recycle bin. Claude-Session: https://claude.ai/code/session_01FEkQ5kYWTJtoyM3pr9E5wF Co-Authored-By: Claude <noreply@anthropic.com>
…rns of a permanent drop Claude-Session: https://claude.ai/code/session_01FEkQ5kYWTJtoyM3pr9E5wF Co-Authored-By: Claude <noreply@anthropic.com>
… and open the list from the Delete press Claude-Session: https://claude.ai/code/session_01FEkQ5kYWTJtoyM3pr9E5wF Co-Authored-By: Claude <noreply@anthropic.com>
…tion Claude-Session: https://claude.ai/code/session_01FEkQ5kYWTJtoyM3pr9E5wF Co-Authored-By: Claude <noreply@anthropic.com>
…ning Claude-Session: https://claude.ai/code/session_01FEkQ5kYWTJtoyM3pr9E5wF Co-Authored-By: Claude <noreply@anthropic.com>
Contributor
Author
|
domain:ui#1 · os-project-manager · session_01FEkQ5nLA7wiVY5YWjT9Svr Contract reviewServed-tier: The lane seat's own review of record, owed by the ① Derived judgments
② Semver level
③ Boundary flags
Implemented-by: VERDICT: PASS |
Contributor
Author
|
domain:ui#1 · os-project-manager · session_01FEkQ5nLA7wiVY5YWjT9Svr 席位核对 · ACCEPT · 2026-11-07T17:18Z · head
|
This was referenced Nov 7, 2026
rajeev-kumar-se
pushed a commit
to rajeev-kumar-se/objectstack
that referenced
this pull request
Nov 10, 2026
…oval (objectstack-ai#32028) <!-- claude-projects-attribution: {"github_login":"os-support-ai"} --> _Requested by **Yibo Wang** · [project thread](https://claude.ai/code/project/chan_01BVUyyPie8gHwoPM18iABwB?thread=cmsg_01BVUyyPie8gHwoPM18iABwBGKmJknJnqwh1BakWHY3yHx)_ Fixes objectstack-ai#31025 Clause-②: yes (widening) Metadata-protocol: none ## 维护者速读 - 改了什么:AI 聊天里,助手发起「删除软件包」时,不再只显示通用的「批准 / 拒绝」和一段 JSON,而是一张确认卡:列出每个对象及其记录数(草稿对象写明尚无数据表,数不出来的写明无法获取,都不显示成 0)、其他元数据按类型计数、总记录数(有对象数不出来时注明总数偏少),并在删表时用红字写明表会被永久删除、不进回收站;保留数据时写明表和记录都保留。批准后卡片写明已删除或部分删除(几项未能移除)。 - 为什么改:这是 objectstack-ai#31025 的第二半(第一半 Studio 删除对话框已在 objectstack-ai#31193 合并)。cloud 的 `delete_package` 工具(cloud#3686)已经返回 `packageRemoval` 清单,聊天却画不出来,cloud#3656(p1)卡在这里。 - 风险与回滚:只改前端渲染和文案;批准 / 拒绝仍走原来的 `/api/v1/ai/pending-actions/:id/{approve,reject}`,卡片不回传任何东西。没有 `packageRemoval` 的结果完全不受影响。回滚即还原本 PR。 - 先看:`ui/packages/plugin-chatbot/src/mapMessages.ts`(`detectPackageRemoval`:`rows` 缺失保持缺失、不当 0)、`ui/packages/plugin-chatbot/src/ChatbotEnhanced.tsx`(`data-testid="package-removal"` 那一块,`data === 'dropped'` 才画永久删除行)、`ui/packages/app-shell/src/console/ai/AiChatPage.tsx`(标签接线和刷新后的复原)。 - 两分钟验证:`pnpm --dir ui exec vitest run packages/plugin-chatbot/src/__tests__/recordWrite-3565.test.ts packages/plugin-chatbot/src/__tests__/ChatbotEnhanced.recordWriteCard-3565.test.tsx`,预期 39 个用例全绿,其中「the package-removal card (objectstack#31025)」一组 10 个。 - 需要你做的:无,席位落地。 ## What changes The chat draws a confirm card for cloud's `delete_package` pending action, built on the shape the `repo:cloud` lane put on objectstack-ai#31025 (comment 6754040588, read at cloud `d6288d27`; tool from cloud#3686) and nothing beyond it. - **Parser** (`ui/packages/plugin-chatbot/src/mapMessages.ts`): `PackageRemoval` / `PackageRemovalObject` and `detectPackageRemoval(result)`, beside `detectSampleDataCleanup` and built on `detectPendingApproval`. An envelope without `pendingActionId` or without a `packageRemoval` object is not a card, so a refusal (`success: false`) and the MCP door's `status: 'confirmation_required'` draw none. Counts are normalised to non-negative whole numbers; an object's `rows` that is absent (or not a usable number) stays absent, never `0`; `totalRows` falls back to the sum of counted rows. The live mapper carries it on the tool invocation like `sampleDataCleanup`, and `AiChatPage`'s hydration mapper lifts it too, so the card survives a reload. `detectPackageRemovedResult` reads the approved outcome (`PackageRemovedResult`: `removed` or `partial` with the `failed` count). - **Card** (`ChatbotEnhanced.tsx`, a `packageRemoval` block beside the `sampleDataCleanup` one, above the generic Approve / Deny strip, which stays the decision): the package label in the title; each object with its record count, a draft saying it has no table and an uncounted object saying its count is unavailable (neither draws a number); the other items by type from `items`; the total, plus a line when `uncountedObjects > 0` that the total leaves those objects out; when `data === 'dropped'` a destructive line that the tables are dropped permanently and do not go to the recycle bin, and when `data === 'kept'` a line that the tables and their records are kept. The raw pending payload stays hidden, as for the sample-data card. - **Outcome**: measured first. On an approved pending action the chat's generic decision strip says "Approved — action executed." whatever the result (`useHitlInChat` sets that text and keeps the result aside), so a partial removal would read as fully executed. The card now adds one line: removed, or partly removed with the number of items not removed. Nothing larger. - **Labels**: `packageRemoval*Label` props with English defaults, wired from `AiChatPage` to new `console.ai.packageRemoval*` keys in every `@object-ui/i18n` pack (zh-Hant through `gen:zh-hant`). Wording reuses Expected 1's studio strings where the fact is the same ("Record count unavailable", the permanent-drop sentence); type names come from the same `translateMetadataType` table the Studio Delete package dialog uses. No server, `packages/spec/**` or cloud change: the payload is a tool-result string the chat already parses. ## Tests Both in the existing cloud#3565 harness files, each as a new top-level `describe` (AGENTS.md: a new pin for a component that already has a shared harness goes into that file). - `recordWrite-3565.test.ts`: a full envelope maps (bare and persisted-wrapper shapes); an absent `rows` stays absent while a real `0` stays `0`; no `pendingActionId`, no `packageRemoval`, a refusal and `confirmation_required` each map to undefined; defensive normalisation; the live mapper lifts it beside the pending id; the outcome parser reads `removed` / `partial` and nothing else. - `ChatbotEnhanced.recordWriteCard-3565.test.tsx` (real mapper, real component): objects, counts, items and total render and the generic decision fires `onToolApprove('c1', true)`; a draft and an uncounted object draw no digit; the permanent line renders for `dropped` (CONTROL: `kept` draws the kept line and no permanent line); the short-total line renders only when `uncountedObjects > 0` (CONTROL: all counted, no line); a refusal draws no card; an approved removal says removed, a partial one names the failed count, a rejection draws no outcome. ## Acceptance notes - `Clause-②: yes (widening)`, measured on the diff: the published `@object-ui/i18n` catalogue gains the `console.ai.packageRemoval*` keys and changes none; `@object-ui/plugin-chatbot` gains exports and optional props. The claim wrote `Clause-②: yes` without an arm; the order named `(widening)`. - `@object-ui/app-shell` is private, so the changeset names `@object-ui/plugin-chatbot` and `@object-ui/i18n` only. - eslint over the touched source files: 0 errors; `index.tsx` carries one more `react-refresh/only-export-components` warning than on `main` (the new `detectPackageRemoval` re-export, the same rule its siblings already trip). - Neither `plugin-chatbot`'s README nor `content/docs/frontend/` documents the sibling chat cards (record write, sample-data cleanup), so no doc page gained a section here. - No browser leg: the agent runtime behind `/api/v1/ai/**` is not in this repository, so the card is pinned through the real mapper and component; the staging reading is cloud#3656's done-when. ## Verification Head: `8d83e7c7` (the fix `44a35169`, the changeset `226b1310`, `origin/main` `bf40cc1f` merged; nothing it brought touches these packages). Readings on the shared box under `scripts/pm/os-verify-lock.sh`, each exit taken from the lock's `VERDICT` line. <details><summary>Tests and type-check</summary> - `pnpm --dir ui exec vitest run packages/plugin-chatbot/src/__tests__/recordWrite-3565.test.ts packages/plugin-chatbot/src/__tests__/ChatbotEnhanced.recordWriteCard-3565.test.tsx`: Test Files 2 passed (2), Tests 39 passed (39), VERDICT command-exit 0 (after the `@object-ui/app-shell^...` closure build, VERDICT 0). - `pnpm --dir ui exec vitest run --maxWorkers=2 packages/plugin-chatbot/ packages/i18n/`: Test Files 195 passed (195), Tests 2752 passed, 13 skipped, VERDICT 0. - Every app-shell test file that names `AiChatPage` (54 files): Test Files 54 passed (54), Tests 417 passed, VERDICT 0. - `pnpm --filter @object-ui/plugin-chatbot --filter @object-ui/i18n --filter @object-ui/app-shell run type-check` (each `tsc --noEmit` plus its `tsconfig.test.json`, which compiles the harness files): all three Done, VERDICT 0. - `ui` `check:i18n-keys`, `check:i18n-drift` (18 en keys added, 0 en values changed), `check:i18n-dead-keys` (no `packageRemoval` key listed), `check:new-line-citations` (0 new): exit 0. `node scripts/check-sdui-manifest.mjs`: exit 0. </details> <details><summary>Ablations (scripts/ablation-replace.mjs, each anchor hit once, each restored with git diff HEAD empty)</summary> - The permanent line ignores `data` (`tool.packageRemoval.data === 'dropped'` replaced by `true`): "CONTROL: kept data draws the kept line and no permanent line" red, 1 failed, 20 passed; restored, blob equals HEAD `c1b46b73`. - A missing `rows` read as `0` (the conditional spread replaced by `rows: rows ?? 0`): four tests red ("lifts the plan…", "keeps an absent row count absent, never 0", "normalises counts defensively…", and the card's "a draft object … neither draws a number"), 4 failed, 35 passed; restored, blob equals HEAD `f3e880ee`. - `ui` vitest resolves `plugin-chatbot` from source and the harness imports `../mapMessages` directly, so no dist preflight sits on these paths. </details> <details><summary>Derived gates</summary> `node scripts/pm/dispatch-gates.mjs --commands --repo objectstack-ai/objectstack` at `8d83e7c7`: 40 families, each run with its exit captured before any pipe, all 40 exit 0. `--ran`: "40 derived famil(ies) accounted for — 40 run, 0 NOT-MEASURED". CI families are read from this PR's check-runs, not re-run locally. </details> --- _Generated by [Claude Code](https://claude.ai/code/session_01WGufzfqZRktLWvgfHqWsyA)_ --------- Co-authored-by: Claude <noreply@anthropic.com> Co-authored-by: objectstack-fleet[bot] <332303061+objectstack-fleet[bot]@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Requested by Leehom · project thread
Part of #31025 — this lands Expected 1 (the Delete package dialog states what goes). Expected 2, the
packageRemovalchat confirm card, stays on the card: its payload is produced only in the cloud repository, which this lane cannot read, and the seat ruled the shape is not to be guessed.Clause-②: yes (widening) — measured on this diff: the published
studiocatalogue of@object-ui/i18ngains ten keys and changes or removes none.Metadata-protocol: none
维护者速读
GET /api/v1/packages/:id/export和每个对象一次$top=0的数据计数;读失败只显示一行说明,删除照常可用。回滚即 revert。PackagesPage.tsx里打开确认框时读取的那个 effect;packageRemovalContents.ts如何把导出结果折成按类型计数;PackageRemovalSummary.tsx永久删除提示的显示条件。pnpm --dir ui exec vitest run packages/app-shell/src/views/metadata-admin/PackagesPage.confirmFlows-11784.test.tsx,预期Tests 20 passed (20)。What changes
ui/packages/app-shell/src/views/metadata-admin/PackagesPage.tsx: pressing Delete package marks the list loading and opens the dialog; while the dialog is open, an effect keyed on the package id readsGET /api/v1/packages/:id/export(the page's existingapiJson), then counts each object's rows through the data source the Console already uses for record counts (useAdapter().find(name, { $top: 0 }), readingtotal, asobjectViewLiveData.tsandDraftChangesPanel.tsxdo). The adapter is read through a ref, so the effect keys on the id alone (uiAGENTS.mdchore: version packages #10). Closing the dialog cancels the reads in flight.packageRemovalContents.ts(new): reads the export answer into what the dialog lists. Each collection key is folded to its singular type withcanonicalMetaUrlType(@objectstack/spec/shared);viewItems(ASSEMBLED_VIEW_ITEMS_KEY,@objectstack/spec/ui) counts as views;withheldMaps, the export's one declared list that is not a collection, is skipped. Objects keep their name and label for the count rows.PackageRemovalSummary.tsx(new): the list (each object with its count, then each other type with its count), the pending-drafts line from the drafts the sheet already reads, and the permanent-drop warning. The warning shows only when the author chose to drop the data, and not when the package is known to hold no object. A count the data list does not answer reads "Record count unavailable", never0. An export the server refuses reads "Could not read what the package holds. Deleting it still removes everything in it.", and the delete stays available.ui/packages/i18n/src/namespaces/studio/{en,zh}.ts: tenengine.packages.detail.delete*strings in both catalogues..changeset/31025-delete-package-contents.md:@object-ui/i18npatch (the namespace ships in itsdist) with both declaration lines.@object-ui/app-shellis private.Tests
Five cases in a new top-level
describeof the shared delete harness,PackagesPage.confirmFlows-11784.test.tsx, driving the realPackageDetailSheetthrough clicks (Delete package, the mode radios, the name input, Confirm):1234 records,1 record) and the other items by type (views folded fromviews+viewItems, dashboards, flows, object extensions);withheldMapsis not listed; the drafts line; each count isfind(name, { $top: 0 }); opening the list writes nothing;totaland a rejected count both read "Record count unavailable", not0;The harness gains a module-top
import '@objectstack/formula'andimport '@objectstack/lint'(check:test-source-aliasasks it of an edited file whose source reaches them through a dynamic import), avi.mockof@object-ui/reactwhoseuseAdapteranswersnullunless a case installs a data source, and an export answer the stub serves.Ablations (
scripts/ablation-replace.mjs, each anchor hit once, each restored to the HEAD blob withgit diff HEADempty):totalcounted as0withheldMapsnot skippedThe fourth ablation's first attempt was refused by the tool (its replacement text already occurred in the file) and restored; it was re-run with a unique replacement.
Acceptance notes
assemblePackageManifest: "not consumed by registerApp"), while the delete removes them too, so those two types are not counted in the dialog. The dialog's description line above the list is unchanged. Not filed; named here for the seat.totalis the rows the caller can read, the figure the object list's footer shows. Dropping a table removes every row in it, which can be more than the caller sees under row-level sharing.studio.accessorsetup.access; the delete door asksmanage_metadata. A caller who holds only the second sees the "could not read" line and can still delete.packageRemovalis not in this PR (seat ruling): the payload is produced by cloud'sdelete_package, the cloud repository is out of this lane's reach, and nothing onmainspells it.Verification
All local readings below are at head
d869c685unless a line names another (base8ef4d309,origin/mainwhen the branch was cut). The last commit only changed the changeset'sClause-②:arm; the families that read a changeset were re-run on it.Tests, type-check and lint
pnpm --dir ui exec vitest run packages/app-shell/src/views/metadata-admin/PackagesPage.confirmFlows-11784.test.tsx packages/i18n/src/__tests__/studio-namespace.test.ts(under the verify lock, at7dcc7b0d, whose source equals this head's): Test Files 2 passed (2), Tests 38 passed (38).pnpm --dir ui exec vitest run packages/app-shell/src/views/metadata-admin/ packages/i18n/src/__tests__/studio-namespace.test.ts(atc8a24f8c, before the harness's two module-top imports): Test Files 731 passed (731), Tests 7780 passed, 1 skipped.pnpm --filter @object-ui/app-shell run type-check(tsc --noEmitandtsc -p tsconfig.test.json, which compiles the harness): exit 0, afterpnpm --workspace-concurrency=2 --filter '@object-ui/app-shell^...' build(VERDICT command-exit 0).pnpm exec eslintfromui/over the three app-shell source files: exit 0, 0 errors, 15 warnings, the same 15 thatPackagesPage.tsxonorigin/maincarries alone (the new files add none).pnpm --dir ui run check:new-line-citations: 0 new citations.check:i18n-keys,check:i18n-drift,check:i18n-dead-keys: exit 0 each; the dead-key report names none of the new keys.Derived gates (dispatch-gates --commands, 36 families)
dispatch-gates.mjs --ran: "36 derived famil(ies) accounted for — 36 run, 0 NOT-MEASURED".7dcc7b0d; ond869c685the changeset readers were re-run (check-adr-0087-registration --base origin/main,check-changeset-no-major,check-empty-changeset,check:changeset-gate-self-tests,check:nul-bytes,check-closing-keyword-parity,check:published-files), all exit 0.pnpm check:test-source-aliaswas exit 1: the edited harness reaches@objectstack/formulaand@objectstack/lintthrough the page's dynamic imports. Fixed by the two module-top imports; exit 0 after.Not measured locally: a live Console check against a booted server (the export answer in the pins is shaped from
PackageExportManifestSchema), and the CI-owned families (Test UI,Lint UI,Type Check UIand the rest), read from this PR's check runs.Generated by Claude Code