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 6b125a7
Browse filesBrowse the repository at this point in the historyBrowse files
feat(console): an admin can open a read-only package's app in Studio to look at it (#28076)
<!-- claude-projects-attribution: {"github_login":"os-bill"} -->
_Requested by **Bill** · [project
thread](https://claude.ai/code/project/chan_016iMXWSZDzqWRWvWzdNo8wg?thread=cmsg_016iMXWSZDzqWRWvWzdNo8wg4i9JiKjEjwtuVzd4gKy9hB)_
## 维护者速读
- 改了什么:只读软件包(代码包或已安装包,例如 HotCRM)的应用,管理员现在在顶栏能看到一个眼睛按钮「Open app in
Studio」,在应用切换器里能看到「在 Studio 中查看 {app}」,打开的是 Studio 的只读浏览;可写包仍是铅笔「Edit」。
- 为什么改:#27356 第 12 行,按你的裁决 B(评论
6520616687):「ai写完代码,人类需要进去确认啊」。objectui#12615 的理由只排除铅笔,不排除入口。
- 风险与回滚:只多画一个入口,不放开任何写权限;同一批管理员、同一道门;内核包、清单里没有的包、清单未读到时仍什么都不画。回滚就是
revert 本 PR。
- 先看:`hooks/useStudioDesignGate.ts` 的 `useStudioEntryGate`(同一次
`writable` 读出 edit / view 两种姿态),`AppHeader.tsx` 顶栏按钮,`AppSwitcher.tsx` 的
Studio 行。
- 两分钟验证:`pnpm --dir ui exec vitest run
packages/app-shell/src/layout/__tests__/AppHeader.editAppFollowsPackagePosture-12615.test.tsx
packages/app-shell/src/layout/__tests__/AppSwitcher.homeMenu-12605.test.tsx`,应见
2 files passed。
- 需要你做的:无,席位落地。
Part of #27356 (row 12, hotcrm#2320 Studio S1: a read-only package's app
opens in Studio to look at it; maintainer-ruled B, comment 6520616687)
Clause-②: no
Metadata-protocol: none
## What changes
- **The gate answers a posture.** `useStudioEntryGate(path)` (new,
`hooks/useStudioDesignGate.ts`) reads the same two halves as before (a
workspace admin holding `manage_metadata`; the package as Studio's
package list carries it) and answers `{ path, posture }`: `edit` for a
package the list carries `writable`, `view` for one it carries
read-only, `null` otherwise. The posture comes from the server's
`writable` verdict read once, in `packageStudioPosture`; no second
derivation. `useStudioDesignGate` is now the `edit` half of that answer,
so the sidebar ⋯ menu's Design entry and a page's Edit in studio pencil
are unchanged.
- **App bar.** `edit` keeps the pencil, 「Edit app」. `view` draws an eye
in the same slot, 「Open app in Studio」
(`data-testid="app-view-in-studio-button"`), to the same Studio path,
which Studio opens in its read-only posture.
- **App switcher.** A new `studioPosture` prop (default `edit`): `view`
turns the last row into 「Open APP in Studio」 with an eye
(`app-switcher-view-in-studio`); `edit` keeps 「Edit APP in Studio」 with
the pencil.
- **Kernel packages still draw nothing.** A manifest-scoped kernel
package is already left out of the list. A kernel package the registry
half serves flat (its `scope` top level) stays in the list read-only,
because the list's visibility filter reads the manifest's `scope` only;
`parsePackages` now marks such a row `kernel: true` (visibility
unchanged), and the gate answers `null` for it. Without this the Setup
app would have got the eye.
- **i18n.** Two keys added in all ten locales: `topbar.openAppInStudio`
(en 「Open app in Studio」, zh 「在 Studio 中查看应用」) and
`layout.appSwitcher.openAppInStudio` (en 「Open {{app}} in Studio」, zh 「在
Studio 中查看 {{app}}」). No key renamed, no en value changed.
- The surface grew, as the ruling grants, by `layout/**` and `hooks/**`;
none of the files open PRs hold (`UnifiedSidebar.tsx`,
`ConsoleLayout.tsx` and the rest of the seat's list) is touched.
`views/studio-design/packages-io.ts` is in the order's Studio surface.
## Tests
- `AppHeader.editAppFollowsPackagePosture-12615.test.tsx` (real
`AppHeader`, router and `MePermissionsProvider`, packages served at
`fetch`): its reading now carries the eye and the switcher's posture
too. The read-only package (HotCRM, `writable: false`) case changes from
"nothing" to "no pencil, the eye to
`/studio/app.objectstack.hotcrm/interfaces?surface=dashboard:pipeline`,
the switcher row to the same target in `view`, named 「Open app in
Studio」". The writable CONTROL reads the pencil with posture `edit` and
no eye. Setup, the unlisted package, the flat-served system package, the
in-flight read and the failed read each read no pencil, no eye and no
switcher row.
- `AppSwitcher.homeMenu-12605.test.tsx` gains two cases: `view` draws
「Open HotCRM in Studio」 with the eye glyph and no Edit row; `edit` keeps
「Edit HotCRM in Studio」 with the pencil (the file's first case already
reads the row with no posture passed).
<details><summary>Readings (head 6f086f6, branch rebuilt from
origin/main bc496bf after #27978 merged; install and app-shell closure
rebuilt)</summary>
- The two pinned files: 2 passed.
- Every ui test file naming `useStudioDesignGate`, `AppHeader`,
`AppSwitcher`, `SidebarItemMenu`, `parsePackages`, `fetchPackages` or
`packages-io`, plus the whole `packages/i18n/`: 326 files, 3011 passed /
13 skipped.
- `pnpm --filter @object-ui/app-shell --filter @object-ui/i18n run
type-check`: exit 0 (lock VERDICT command-exit 0).
- Ablation 1, through `scripts/ablation-replace.mjs`: `return
pkg.writable ? 'edit' : 'view';` to `... : null` (the read-only package
gets nothing, as before): 1 failed / 8 passed (the HotCRM case red);
restored blob = HEAD blob `df9f158d1490`, `git diff HEAD` empty.
- Ablation 2: `if (!pkg || pkg.kernel) return null;` to `if (!pkg)
return null;` (the flat-served kernel row gets the eye): 1 failed / 8
passed (the flat system package case red); restored, `git diff HEAD`
empty.
- vitest resolves `@object-ui/*` to source, so neither ablation needed a
rebuild.
- `pnpm --dir ui run check:i18n-drift`: 0 en values changed (2 keys
added, all ten packs).
</details>
## Acceptance notes
- **Row 14 is answered C (will not do), per the ruling.** The Data
pillar's grid columns, its Form canvas and the one field inspector are
the object's field designer; objectui#5813 ("fields ARE the grid's
columns, so a separate fields tab would ADD a surface") and the
seven-tab ruling of objectui#12450 (decision B of objectui#12446) stand.
No change for row 14.
- Row 19 (Delete flow in Studio, ruled A1) follows as its own PR after
this one.
- The eye opens Studio where the pencil would have
(`appStudioRoutePath`'s deep link). Studio's own read-only posture (row
13, #27927) is what the viewer then sees; this PR promises a look, not
an edit, and the server's write gate is unchanged.
- The `kernel` mark reads a flat row's top-level `scope`, the position
the registry half serves; it changes no visibility. Whether a real
server serves Setup flat was not measured here; the existing pin says it
does.
## Verification
On head `6f086f63`: `dispatch-gates --commands` derived 34 families for
this diff; all 34 were run locally, each exit 0, and `--ran` reconciled
34 run, 0 NOT-MEASURED, 0 UNRUN. `check:new-line-citations`: 0 new. CI
check-runs were in progress when this was opened.
---
_Generated by [Claude
Code](https://claude.ai/code/session_01Utp6CZrsFMFmWFsxTaq2Bu)_
Co-authored-by: Claude <noreply@anthropic.com>
feat(console): an admin can open a read-only package's app in Studio to look at it
7
+
8
+
Clause-②: no
9
+
Metadata-protocol: none
10
+
11
+
The app bar's Edit app pencil and the app switcher's 「Edit APP in Studio」 row were drawn only for an app whose package Studio lists as writable (objectui#12615), so a code or installed package's app (HotCRM, for one) offered no way into Studio at all. The same metadata authors now get a browse entry for such an app: an eye in the app bar, 「Open app in Studio」, and 「Open APP in Studio」 in the switcher, landing where the pencil would, in Studio's read-only posture. A writable package's app keeps the pencil and 「Edit APP in Studio」. The console's own apps, a package the list does not carry and a list not yet read still draw neither.
12
+
13
+
`useStudioEntryGate` answers the gate with a posture (`edit` or `view`) from the same server `writable` verdict; `useStudioDesignGate` is its `edit` half, so the sidebar's Design entry and a page's pencil are unchanged. Two keys are added in all ten locales: `topbar.openAppInStudio` and `layout.appSwitcher.openAppInStudio`.
it('#27356 row 12 — a read-only package (HotCRM, `writable: false`) gets no pencil but the eye, and the switcher row in the view posture, to the same target',async()=>{
281
+
expect(awaiteditAppOn(HOTCRM_ROUTE)).toEqual({
282
+
pencil: null,
283
+
eye: HOTCRM_VIEW,
284
+
switcherRow: HOTCRM_VIEW,
285
+
switcherPosture: 'view',
286
+
});
287
+
mountAt(HOTCRM_ROUTE);
288
+
awaitsettle();
289
+
expect(screen.getByLabelText('Open app in Studio')).toBeInTheDocument();
265
290
});
266
291
267
292
it('CONTROL — the pencil for a writable package, deep-linked, and the switcher row to the same target',async()=>{
0 commit comments