@@ -15,6 +15,7 @@ import type { Database } from "../storage/database.js";
1515import type { SupervisorManager } from "../supervisor/manager.js" ;
1616import type { TerminalManager } from "../terminal/manager.js" ;
1717import type { WorkspaceManager } from "../workspace/manager.js" ;
18+ import type { ActivationManager } from "./activation.js" ;
1819import type { FencingManager } from "./fencing.js" ;
1920import type { Broadcaster } from "./hub.js" ;
2021
@@ -34,6 +35,7 @@ export interface CommandContext {
3435 autoFetch : AutoFetchRuntime ;
3536 providerRuntimeDeps ?: RuntimeStatusDeps ;
3637 providerInstallMgr ?: ProviderInstallManager ;
38+ activationMgr : ActivationManager ;
3739}
3840
3941/**
@@ -56,6 +58,12 @@ const handlers = new Map<string, CommandHandler>();
5658 * Registry of all command schemas
5759 */
5860const schemas = new Map < string , CommandSchema > ( ) ;
61+ const ACTIVATION_ALLOWLIST = new Set ( [
62+ "activation.claim" ,
63+ "activation.heartbeat" ,
64+ "activation.release" ,
65+ "connection.probe" ,
66+ ] ) ;
5967
6068/**
6169 * Register a command handler
@@ -77,6 +85,21 @@ export async function dispatch(
7785 ctx : CommandContext ,
7886 clientId ?: string
7987) : Promise < Result > {
88+ if ( ! ACTIVATION_ALLOWLIST . has ( msg . op ) ) {
89+ const lease = ctx . activationMgr . getLease ( ) ;
90+ if ( ! clientId || ! lease || lease . wsClientId !== clientId ) {
91+ return {
92+ kind : "result" ,
93+ id : msg . id ,
94+ ok : false ,
95+ error : {
96+ code : "activation_required" ,
97+ message : "This tab is no longer the active session" ,
98+ } ,
99+ } ;
100+ }
101+ }
102+
80103 const handler = handlers . get ( msg . op ) ;
81104
82105 if ( ! handler ) {
0 commit comments