typescript: add managed subscription lifetimes - #423
Conversation
|
Follow-up integration is ready on the fork branch pr/typescript-managed-host-subscriptions at 7ac6302. It preserves one managed lease across real MultiHostClient transport generations, routes replay/snapshot/missing restoration into that lease, and fences stale generation events and results. The full TypeScript suite is 78/78; focused host and reconnect suites are green. I kept it out of this PR so the shared subscription lifetime can be reviewed independently. The coordinated VS Code consumer and deletion proposal is microsoft/vscode#332854. |
| export interface ManagedSubscriptionLease { | ||
| readonly subscription: ManagedSubscription; | ||
| readonly events: AsyncIterableIterator<SubscriptionEvent>; | ||
| release(): void; |
There was a problem hiding this comment.
Prefer Symbol.dispose for fully RAII-style usage
| * options; conflicting options throw rather than silently changing the | ||
| * already-active server subscription. | ||
| */ | ||
| acquire( |
There was a problem hiding this comment.
I suggest allowing the consumer to spec the type of state and events they're getting here.
We actually have some prior art for this in vscode sources, see these methods and IAgentSubscription https://github.com/microsoft/vscode/blob/c19945aab6c07dac9e1afd386704af16a4d212c7/src/vs/platform/agentHost/common/agentService.ts#L1046-L1054
This comment was marked as spam.
This comment was marked as spam.
5c577c6 to
2e14524
Compare
Summary
Add a framework-neutral ManagedSubscriptionManager to the official TypeScript client entry point. It provides reusable ownership and lifecycle semantics above the existing subscribe and unsubscribe wire methods without adding protocol vocabulary.
The manager owns:
It deliberately does not import VS Code Event, observable, URI, Disposable, DI, or workbench abstractions. Reducer-backed state, optimistic action reconciliation, and multi-host reconnect restoration remain separate SDK decisions.
Why this belongs in the SDK
Subscriptions are already an AHP protocol concept, and the official client already owns the wire subscription plus state-mirror primitives. Reference ownership, initial-roundtrip delivery, deterministic reacquisition, and final unsubscribe are generic client lifecycle rules; leaving them to each product produces multiple subscription managers above the same SDK.
Validation
The implementation is stateless when a subscription returns no snapshot, so it also supports notification-only resources.