From a2c5d40e3029c86705ff34b6a340eabdf9079765 Mon Sep 17 00:00:00 2001 From: mektpoy Date: Wed, 21 Oct 2026 00:08:35 +0800 Subject: [PATCH] refactor(liveshare-protocol): share the permission facts between request and frame TunnelShareSpec and ShareAccessStateFrame repeated the same six permission fields. They now extend one SharePermissions interface (the committed frame is the authority), with the upload switch optional in a request and required in a frame. The wire shape is unchanged, so the recorded frames replay byte for byte; the display-only and grouping fields plus the registration-token and request-id roles are documented in place. --- .../liveshare-protocol/src/tunnel-protocol.ts | 29 ++++++++++++++++--- 1 file changed, 25 insertions(+), 4 deletions(-) diff --git a/packages/experimental/liveshare-protocol/src/tunnel-protocol.ts b/packages/experimental/liveshare-protocol/src/tunnel-protocol.ts index 34e6f3284d..7e7252d794 100644 --- a/packages/experimental/liveshare-protocol/src/tunnel-protocol.ts +++ b/packages/experimental/liveshare-protocol/src/tunnel-protocol.ts @@ -32,10 +32,28 @@ export const LIVESHARE_CAPABILITIES: readonly string[] = [ 'file-upload', ] +/** + * The permission facts a share publishes. + * + * The owner asks for them in {@link TunnelShareSpec}; the Relay commits them in + * {@link ShareAccessStateFrame}. The committed frame is the authority: a reader follows it, not the + * request that produced it. `allowsFileUpload` is optional here because a request may omit the switch, + * while a committed frame always states it. + */ +export interface SharePermissions { + readonly accessMode: 'open' | 'selected' + readonly allowedSubjectIds: readonly string[] + readonly sessionMode?: 'view' | 'write' + readonly allowsFork?: boolean + readonly allowsFileUpload?: boolean + readonly expiresAt?: string +} + /** One share the owner host asks its gateway worker to carry to the Relay. */ -export interface TunnelShareSpec { +export interface TunnelShareSpec extends SharePermissions { readonly shareId: string readonly sessionId: string + /** Display-only share title; the host refreshes it with `reconcileShareTitles()` when renamed. */ readonly sessionTitle: string readonly accessMode: 'open' | 'selected' readonly relay: string @@ -43,9 +61,12 @@ export interface TunnelShareSpec { readonly ownerProviderId?: string readonly ownerTenantId?: string readonly ownerDisplayName: string - /** Version of the owner's DSH build, shown on the Relay share picker. */ + /** Display-only: the owner's DSH version shown on the Relay share picker. */ readonly dshVersion?: string - /** Stable id of the owner DSH instance that published this share. */ + /** + * Stable id of the owner DSH instance that published this share. Not display-only: the Relay groups + * shares of the same owner instance by it. + */ readonly ownerInstanceId?: string /** * Whether this share lets an admitted viewer fork it. @@ -179,7 +200,7 @@ export interface ShareRpcCancelFrame { } /** Committed Relay authority for one share, scoped to the socket carrying it. */ -export interface ShareAccessStateFrame { +export interface ShareAccessStateFrame extends SharePermissions { readonly type: 'share-access-state' /** Monotonic durable Relay store revision. */ readonly version: number