:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
fix(desktop/web): bind the speech host capabilities on web (#85500)
Ben White9a9a8a3e7494
diff --git a/products/desktop/apps/web/src/web-container.ts b/products/desktop/apps/web/src/web-container.tsindex 58e2da805a15..4d0c28ce4204 100644--- a/products/desktop/apps/web/src/web-container.ts+++ b/products/desktop/apps/web/src/web-container.ts@@ -147,6 +147,13 @@ import type {SkillsWorkspaceClient,TeamSkillsService,} from "@posthog/core/skills/teamSkillsService";+import {+ SPEECH_SETTINGS_PROVIDER,+ SPEECH_USER_NAME_PROVIDER,+ type SpeechSettingsProvider,+ type UserNameProvider,+} from "@posthog/core/speech/identifiers";+import { speechCoreModule } from "@posthog/core/speech/speech.module";import {TASK_CREATION_EFFECTS,TASK_CREATION_HOST,@@ -193,6 +200,7 @@ import {type IPowerManager,POWER_MANAGER_SERVICE,} from "@posthog/platform/power-manager";+import { type ISpeech, SPEECH_SERVICE } from "@posthog/platform/speech";import type { Adapter } from "@posthog/shared";import { sandboxProxyHtml } from "@posthog/shared/mcp-sandbox-proxy";import { authUiModule } from "@posthog/ui/features/auth/auth.module";@@ -246,7 +254,9 @@ import {ACTIVE_VIEW_PROVIDER,type IActiveView,type INotificationSettings,+ type ISpeechNotifySettings,NOTIFICATION_SETTINGS_PROVIDER,+ SPEECH_NOTIFY_SETTINGS,} from "@posthog/ui/features/notifications/identifiers";import { notificationsUiModule } from "@posthog/ui/features/notifications/notifications.module";import { OnboardingGithubConnectClient } from "@posthog/ui/features/onboarding/githubConnectClientImpl";@@ -322,6 +332,12 @@ import {} from "./web-sessions-clients";import { webSetupStore } from "./web-setup-store";import { webShellClient } from "./web-shell-client";+import {+ createWebSpeechUserName,+ webSpeech,+ webSpeechNotifySettings,+ webSpeechSettings,+} from "./web-speech";import {webTaskDeletionHost,webTaskDeletionWorkspaceClient,@@ -403,6 +419,10 @@ interface WebBindings {[NOTIFICATIONS_SERVICE]: INotifications;[NOTIFICATION_SETTINGS_PROVIDER]: INotificationSettings;[ACTIVE_VIEW_PROVIDER]: IActiveView;+ [SPEECH_SERVICE]: ISpeech;+ [SPEECH_SETTINGS_PROVIDER]: SpeechSettingsProvider;+ [SPEECH_USER_NAME_PROVIDER]: UserNameProvider;+ [SPEECH_NOTIFY_SETTINGS]: ISpeechNotifySettings;[REPORT_MODEL_RESOLVER]: ReportModelResolver;}@@ -809,6 +829,18 @@ container.toConstantValue(webNotificationSettings);container.bind(ACTIVE_VIEW_PROVIDER).toConstantValue(webActiveView);+// ── Spoken notifications ──+// SpeechNotifier (notificationsUiModule) is what SessionService resolves for+// agent narration, so the whole chain down to the platform ISpeech has to be+// bound here too. Web speaks with the browser's system voice.+container.load(speechCoreModule);+container.bind(SPEECH_SERVICE).toConstantValue(webSpeech);+container.bind(SPEECH_SETTINGS_PROVIDER).toConstantValue(webSpeechSettings);+container+ .bind(SPEECH_USER_NAME_PROVIDER)+ .toConstantValue(createWebSpeechUserName(queryClient));+container.bind(SPEECH_NOTIFY_SETTINGS).toConstantValue(webSpeechNotifySettings);+// ── Inbox: resolve the default cloud-run model from the LLM gateway ──// Host capability consumed by UI hooks (canvas/home/inbox) that create cloud// runs. Same logic as desktop-services.ts, over the web host router'sdiff --git a/products/desktop/apps/web/src/web-speech.ts b/products/desktop/apps/web/src/web-speech.tsnew file mode 100644index 000000000000..9ee520833a36--- /dev/null+++ b/products/desktop/apps/web/src/web-speech.ts@@ -0,0 +1,57 @@+import type {+ SpeechSettingsProvider,+ UserNameProvider,+} from "@posthog/core/speech/identifiers";+import type { ISpeech } from "@posthog/platform/speech";+import { authKeys } from "@posthog/ui/features/auth/useCurrentUser";+import type { ISpeechNotifySettings } from "@posthog/ui/features/notifications/identifiers";+import { useSettingsStore } from "@posthog/ui/features/settings/settingsStore";+import type { ImperativeQueryClient } from "@posthog/ui/shell/queryClient";+import {+ isSpeechSupported,+ speakSystemVoice,+ stopSpeech,+} from "@posthog/ui/utils/speech";++// System voice only: ElevenLabs synthesis needs the key in a host secure store,+// which the browser has no equivalent of. voiceId is therefore ignored.+export const webSpeech: ISpeech = {+ isSupported: () => isSpeechSupported(),+ speak: (text) => speakSystemVoice(text),+ stop: () => stopSpeech(),+};++export const webSpeechSettings: SpeechSettingsProvider = {+ get: () => ({ enabled: useSettingsStore.getState().spokenNotifications }),+};++export const webSpeechNotifySettings: ISpeechNotifySettings = {+ get: () => {+ const s = useSettingsStore.getState();+ return {+ enabled: s.spokenNotifications,+ needsInput: s.spokenNotifyNeedsInput,+ completion: s.spokenNotifyCompletion,+ progress: s.spokenNotifyProgress,+ focusMode: s.spokenFocusMode,+ };+ },+};++export function createWebSpeechUserName(+ queryClient: ImperativeQueryClient,+): UserNameProvider {+ return {+ getFirstName: () => {+ for (const [, data] of queryClient.getQueriesData({+ queryKey: authKeys.currentUsers(),+ })) {+ const first = (+ data as { first_name?: string | null } | undefined+ )?.first_name?.trim();+ if (first) return first;+ }+ return undefined;+ },+ };+}diff --git a/products/desktop/packages/ui/src/shell/requiredHostCapabilities.ts b/products/desktop/packages/ui/src/shell/requiredHostCapabilities.tsindex 826b45ec9c59..67adcd67a1c0 100644--- a/products/desktop/packages/ui/src/shell/requiredHostCapabilities.ts+++ b/products/desktop/packages/ui/src/shell/requiredHostCapabilities.ts@@ -1,11 +1,17 @@import { REPORT_MODEL_RESOLVER } from "@posthog/core/inbox/identifiers";+import {+ SPEECH_SETTINGS_PROVIDER,+ SPEECH_USER_NAME_PROVIDER,+} from "@posthog/core/speech/identifiers";import type { HostCapabilityRequirement } from "@posthog/di/hostCapabilities";import { HOST_CAPABILITIES } from "@posthog/platform/host-capabilities";+import { SPEECH_SERVICE } from "@posthog/platform/speech";import { AUTH_SIDE_EFFECTS } from "@posthog/ui/features/auth/identifiers";import { REVIEW_HOST } from "@posthog/ui/features/code-review/reviewHost";import { CONNECTIVITY_CLIENT } from "@posthog/ui/features/connectivity/connectivityClient";import { FEATURE_FLAGS } from "@posthog/ui/features/feature-flags/identifiers";import { GIT_CACHE_KEY_PROVIDER } from "@posthog/ui/features/git-interaction/gitCacheProvider";+import { SPEECH_NOTIFY_SETTINGS } from "@posthog/ui/features/notifications/identifiers";import { UPDATES_CLIENT } from "@posthog/ui/features/updates/updatesClient";import { DIFF_WORKER_FACTORY } from "@posthog/ui/shell/diffWorkerHost";@@ -69,4 +75,20 @@ export const REQUIRED_HOST_CAPABILITIES: readonly HostCapabilityRequirement[] =token: REPORT_MODEL_RESOLVER,description: "default cloud-run model resolution (canvas/home/inbox)",},+ {+ token: SPEECH_SERVICE,+ description: "text-to-speech playback for agent narration",+ },+ {+ token: SPEECH_SETTINGS_PROVIDER,+ description: "spoken-narration enablement and voice",+ },+ {+ token: SPEECH_USER_NAME_PROVIDER,+ description: "signed-in user's first name for spoken greetings",+ },+ {+ token: SPEECH_NOTIFY_SETTINGS,+ description: "per-kind gating for spoken notifications",+ },];