Files
paseo/packages/protocol/src/terminal-subscription-key.ts
T
Mohamed Boudra c4e5a0e739 feat(plugin): observe terminals across connected hosts
Share host-wide terminal observations across plugin surfaces and gate them on terminalCollection. Keep directory observations compatible, and carry creation time in worker v6 state so v5 terminals can drain with an unknown timestamp.
2026-11-06 09:22:19 +01:00

14 lines
689 B
TypeScript

// A terminal directory subscription is scoped to a (cwd, workspaceId) pair, not
// cwd alone: under Model B two workspaces can share a cwd, and each must track
// and tear down its own live subscription without disturbing the other. An
// absent workspaceId (old clients) keys to the cwd on its own. The `::`
// separator cannot collide with a workspace id, which is always `wks_<hex>`.
export function terminalSubscriptionKey(
cwd: string | undefined,
workspaceId: string | undefined,
): string {
if (cwd === undefined)
return workspaceId === undefined ? "terminal-host" : `${workspaceId}::terminal-host`;
return workspaceId === undefined ? cwd : `${workspaceId}::${cwd}`;
}