Skip to content

Commit 623a7d4

Browse files
chore: tighten the shared view-state docs
1 parent c8e5193 commit 623a7d4

3 files changed

Lines changed: 6 additions & 24 deletions

File tree

‎packages/types/src/global-settings.ts‎

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -121,10 +121,7 @@ export const viewStateSchema = z.object({
121121
mode: z.string().optional(),
122122
currentApiConfigName: z.string().optional(),
123123
updatedAt: z.number().optional(),
124-
/**
125-
* Host-minted capability token binding this entry to the webview that wrote it; never
126-
* accepted from webview input and only a matching token re-adopts the entry.
127-
*/
124+
/** Host-minted token binding this entry to the webview that wrote it. */
128125
claimToken: z.string().optional(),
129126
})
130127

‎packages/types/src/vscode-extension-host.ts‎

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -679,10 +679,7 @@ export interface WebviewMessage {
679679
| "themeFixtureProbeResponse"
680680
text?: string
681681
viewStateId?: string
682-
/**
683-
* For `webviewDidLaunch`: the host-minted claim previously delivered for `viewStateId`.
684-
* Enforced by `ClineProvider.setViewStateId`; launch forwarding ships in the wiring unit.
685-
*/
682+
/** For `webviewDidLaunch`: the claim delivered for `viewStateId`, enforced by setViewStateId. */
686683
viewStateClaim?: string
687684
taskId?: string
688685
editedMessageContent?: string

‎src/core/webview/ClineProvider.ts‎

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -376,10 +376,7 @@ export class ClineProvider
376376
*/
377377
public readonly viewId: string
378378

379-
/**
380-
* Stable identifier for persisted per-view state keys; binds a durable entry to the
381-
* webview that wrote it through the host-minted claim token.
382-
*/
379+
/** Stable id for persisted per-view state keys, bound by the host-minted claim. */
383380
private viewStateId: string
384381

385382
/**
@@ -604,10 +601,7 @@ export class ClineProvider
604601
return Object.assign(Object.create(null), viewStates)
605602
}
606603

607-
/**
608-
* Persist the non-secret selections through the serialized write queue, re-keying a
609-
* pre-launch write to the stable id once the webview registers one.
610-
*/
604+
/** Persist the non-secret selections through the serialized write queue. */
611605
private async savePersistedViewState(values: Partial<PersistedViewState>): Promise<void> {
612606
// Capture the id at change time: a write belongs to the view that was active
613607
// when the change was made, even if a newer id is registered while it is queued.
@@ -693,10 +687,7 @@ export class ClineProvider
693687
await write
694688
}
695689

696-
/**
697-
* Re-bind a claim-less viewStates entry with a freshly minted claim; its unowned
698-
* selections are dropped so the new token cannot re-expose them.
699-
*/
690+
/** Re-bind a claim-less entry with a fresh claim; unowned selections are dropped. */
700691
private async rebindUnboundViewStateEntry(viewStateId: string): Promise<string | undefined> {
701692
const claimToken = crypto.randomUUID()
702693
let rebound = false
@@ -797,10 +788,7 @@ export class ClineProvider
797788
await write
798789
}
799790

800-
/**
801-
* Register the stable view id and load its persisted selections. An entry that carries a
802-
* claim is loaded only when the presented host-minted token matches it.
803-
*/
791+
/** Register the stable view id and load its persisted selections; a claim must match. */
804792
public async setViewStateId(viewStateId: string | undefined, presentedClaim?: string): Promise<void> {
805793
// The webview generates this id on purpose - it has to survive a webview reload,
806794
// which recreates the view on both sides - so the host cannot mint it instead.

0 commit comments

Comments
 (0)