@@ -85,26 +85,31 @@ const MetadataResourceHistoryPage = React.lazy(() =>
8585 * verdict rule is the one `parsePackages` applies. One request either way: the
8686 * readers of that endpoint share it (`packages-io.ts`).
8787 */
88- function useListedPackageWritable ( packageId : string | null ) : boolean | null | undefined {
89- const [ answer , setAnswer ] = React . useState < { id : string ; writable : boolean | null } | null > ( null ) ;
88+ function useListedPackageWritable ( packageId : string | null ) : { writable : boolean | null | undefined ; kernel : boolean } {
89+ const [ answer , setAnswer ] = React . useState < { id : string ; writable : boolean | null ; kernel : boolean } | null > ( null ) ;
9090 React . useEffect ( ( ) => {
9191 if ( packageId === null ) return ;
9292 let cancelled = false ;
9393 fetchListedPackageManifests ( ) . then (
9494 ( manifests ) => {
95- if ( ! cancelled ) setAnswer ( { id : packageId , writable : manifests . get ( packageId ) ?. writable ?? null } ) ;
95+ if ( cancelled ) return ;
96+ const listed = manifests . get ( packageId ) ;
97+ // objectstack#36897 — a kernel package (manifest scope `system` or
98+ // `cloud`) has no pair: the ensure door refuses it (ADR-0146 D3).
99+ const scope = listed ?. manifest ?. scope ;
100+ setAnswer ( { id : packageId , writable : listed ?. writable ?? null , kernel : scope === 'system' || scope === 'cloud' } ) ;
96101 } ,
97102 ( ) => {
98103 // The surface reports the failure once (its package-list toast).
99- if ( ! cancelled ) setAnswer ( { id : packageId , writable : null } ) ;
104+ if ( ! cancelled ) setAnswer ( { id : packageId , writable : null , kernel : false } ) ;
100105 } ,
101106 ) ;
102107 return ( ) => {
103108 cancelled = true ;
104109 } ;
105110 } , [ packageId ] ) ;
106- if ( packageId === null ) return null ;
107- return answer ?. id === packageId ? answer . writable : undefined ;
111+ if ( packageId === null ) return { writable : null , kernel : false } ;
112+ return answer ?. id === packageId ? { writable : answer . writable , kernel : answer . kernel } : { writable : undefined , kernel : false } ;
108113}
109114
110115function AreaLoading ( { locale } : { locale : string } ) : React . ReactElement {
@@ -182,15 +187,16 @@ function AreaItemOpen({
182187 * `<root>/:type/new`. A read-only package takes no new item of its own:
183188 * objectstack#36897 — on a read-only base the create is its `.custom` pair's
184189 * (ADR-0146 D3), asked of the ensure door and opened there; where the door
185- * refuses this caller (`customization.walled`), or there is no base to pair,
190+ * refuses this caller (`customization.walled`), the package is a kernel
191+ * package (which has no pair), or there is no base to pair,
186192 * the create URL lands on the list, as before.
187193 */
188194function AreaCreate ( { customization } : { customization : StudioBaseCustomization | null } ) : React . ReactElement {
189195 const { type = '' } = useParams < { type : string } > ( ) ;
190196 const { search } = useLocation ( ) ;
191197 const host = useMetadataAreaHost ( ) ;
192198 if ( host ?. readOnly ) {
193- if ( customization && ! customization . walled ) {
199+ if ( customization && host . pairCreate ) {
194200 return < AreaPairedCreate type = { type } search = { search } customization = { customization } /> ;
195201 }
196202 return < Navigate to = { `${ host . basePath } /${ encodeURIComponent ( type ) } ${ search } ` } replace /> ;
@@ -277,10 +283,11 @@ export function StudioMetadataArea({
277283 // manifests (see the hook). Unknown stays ungated, as on the pillars: the
278284 // server's write gate is the authority, and a failed probe must not lock an
279285 // author out of a writable package.
280- const writable = useListedPackageWritable ( packageId ) ;
286+ const { writable, kernel } = useListedPackageWritable ( packageId ) ;
281287 const readOnly = packageId !== null && writable === false ;
282- // objectstack#36897 — the list offers a create exactly where `AreaCreate` opens one in the pair.
283- const pairCreate = readOnly && ! ! customization && ! customization . walled ;
288+ // objectstack#36897 — the list offers a create exactly where `AreaCreate`
289+ // opens one in the pair; never on a kernel package, which has none.
290+ const pairCreate = readOnly && ! kernel && ! ! customization && ! customization . walled ;
284291 const host = React . useMemo < MetadataAreaHost > (
285292 ( ) => ( { packageId, readOnly, basePath, ...( pairCreate ? { pairCreate } : { } ) } ) ,
286293 [ packageId , readOnly , basePath , pairCreate ] ,
0 commit comments