Repository navigation
fix(studio): action editor grants a sandboxed-JS script body its capabilities - #29288
Merged
Merged
Conversation
…bilities The action inspector kept `capabilities` in the JS body's key set but drew no control for it, so a script action that read or wrote data was refused on every click. Extract the Hook inspector's grant list into a shared ScriptCapabilitiesField and mount it for the L2 action body too. Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QsR2jSEPnzpJUHmt6bHrgt
Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QsR2jSEPnzpJUHmt6bHrgt
Contributor
Author
|
domain:ui#3 · zhuangjianguo · session_01QsR2jV4dWohojjbTJTQq5m 席位核对 · ACCEPT · 2026-11-02T11:24ZHead-sha:
|
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 Steedos · project thread
Fixes #29181
Clause-②: no
Metadata-protocol: none
维护者速读
body.capabilities,编辑器原先没有任何入口,作者发布的动作每次点击都被 403 拒绝,只能改原始元数据。ScriptCapabilitiesField.tsx(新共享控件);ActionDefaultInspector.tsx中bodyLanguageOf(body) === 'js'那一段;HookDefaultInspector.tsx替换处。cd ui && pnpm exec vitest run packages/app-shell/src/views/metadata-admin/inspectors/ActionDefaultInspector.capabilities-29181.test.tsx,预期 6/6 通过。What changes
ScriptCapabilitiesField.tsx(module-private, beside the inspectors, no barrel re-export): the grant list of a sandboxed-JS body. One checkbox perHookBodyCapabilitytoken, read from the spec enum in its order, each naming thectxcall it unlocks; a stored token the enum does not list stays visible and flagged; unticking the last grant writes[], the spec default. The host passes the hint key, so each editor says when a refusal happens.ActionDefaultInspector.tsx: renders that control under the script body when the body's language isjs. Writes go through the existing single body writer (writeScriptBody), solanguageis kept and a switch to an expression body still dropscapabilitieswith the other L2-only keys. An expression body shows no control.HookDefaultInspector.tsx: its inline grant list is replaced by the shared control with the same test id, label, hint, flag and write. Its rendered output and writes are unchanged;HookDefaultInspector.capabilities-26726.test.tsxis untouched and green.ActionSchema.bodyisHookBodySchema, whose L2 arm isScriptBodySchemawithcapabilities: z.array(HookBodyCapability), so the action body uses the same enum as the hook body, and the control is shared rather than duplicated.packages/specis not edited.engine.inspector.action.capabilitiesHint(en, zh), because the hook hint says the call "throws when the hook runs". The label and the unknown-token flag reuse the hook rows. The Studio namespace is not part of the builtlocalessurface, so the claim'sClause-②: nostands..changeset/29181-action-script-capabilities.md,@object-ui/app-shelland@object-ui/i18npatch.Tests
New
ActionDefaultInspector.capabilities-29181.test.tsx(6 cases), driving the real inspector in a host that merges patches the wayObjectActionsPaneldoes, sending the held draft through a JSON round trip and parsing it with the spec'sActionSchema:HookBodyCapability.options; tickingapi.writewritesbody.capabilities: ['api.write']and the action parses.capabilitiesloads with nothing ticked, rendering writes nothing, and a source edit leaves the body without the key.[]; each step parses.Acceptance notes
api.write) is existing behaviour this PR does not touch. Standing in: case 1 above, which proves the editor writes the exactbody.capabilitiesthe runtime's refusal prescribes and thatActionSchemaaccepts it.BODY_KEYS_BY_LANGUAGEin the action inspector stays written out (its comment keeps the spec body schema out of the first load). The shared control importsHookBodyCapabilityfrom@objectstack/spec/data, whichHookDefaultInspectoralready imported in the same registration module (inspectors/index.tsregisters both), so no new spec module reaches any chunk.Verification
Inspector suites (16 files)
pnpm exec vitest run --maxWorkers=2over everyActionDefaultInspector.*.test.tsx,HookDefaultInspector.*.test.tsxandinspectorStrings.hookAction.i18n-10586.test.tsx: Test Files 16 passed (16), Tests 98 passed (98).Ablation (control hidden)
scripts/ablation-replace.mjsreplaced the action inspector'sbodyLanguageOf(body) === 'js'guard withfalse(anchor 1 to 0, blob 182e05bd to 913d95bd): the new file went 5 failed, 1 passed (the expression case, which asserts absence, stays green as expected). Restored: blob equals HEAD,git diff HEADempty.Type-check and lint
turbo run type-check --filter=@object-ui/app-shell --filter=@object-ui/i18n: 66 tasks successful.eslinton the six touched files: 0 errors (one pre-existing warning on the hook inspector's context export).Derived gates
node scripts/pm/dispatch-gates.mjs --commands --repo objectstack-ai/objectstackderived 34 families at b40f1cf; all 34 run, each exit 0;--ranreconciliation: 34 derived, 34 run, 0 NOT-MEASURED, 0 UNRUN. (check:query-options-erasurefirst hit a local 280 s cap, exit 124; re-run alone, exit 0 in 379 s.) After mergingorigin/main(head ede1584): the 16 inspector files 98/98 again, turbo type-check 66/66,check:sdui-manifestexit 0, and the Type Check UI static stepscheck:phantom-deps,check:spec-symbols,check:i18n-keys,check:i18n-drift,check:designer-field-key-parity,check:metadata-write-doorseach exit 0.Generated by Claude Code
🤖 Generated with Claude Code
https://claude.ai/code/session_01QsR2jSEPnzpJUHmt6bHrgt