@@ -6,10 +6,12 @@ import {
66 deriveInitialConfig ,
77} from "@posthog/core/task-detail/previewConfig" ;
88import { useHostTRPCClient } from "@posthog/host-router/react" ;
9- import { getCloudUrlFromRegion } from "@posthog/shared" ;
9+ import { GLM_MODEL_FLAG , getCloudUrlFromRegion } from "@posthog/shared" ;
10+ import { stripGlmModelOption } from "@posthog/ui/features/sessions/modelOptionFilters" ;
1011import { useCallback , useEffect , useMemo , useRef , useState } from "react" ;
1112import { logger } from "../../../shell/logger" ;
1213import { useAuthStateValue } from "../../auth/store" ;
14+ import { useFeatureFlag } from "../../feature-flags/useFeatureFlag" ;
1315import { useSettingsStore } from "../../settings/settingsStore" ;
1416
1517const log = logger . scope ( "preview-config" ) ;
@@ -42,6 +44,7 @@ export function usePreviewConfig(
4244 adapter : "claude" | "codex" ,
4345) : PreviewConfigResult {
4446 const hostClient = useHostTRPCClient ( ) ;
47+ const glmEnabled = useFeatureFlag ( GLM_MODEL_FLAG ) ;
4548 const cloudRegion = useAuthStateValue ( ( state ) => state . cloudRegion ) ;
4649 const apiHost = useMemo (
4750 ( ) => ( cloudRegion ? getCloudUrlFromRegion ( cloudRegion ) : null ) ,
@@ -74,9 +77,13 @@ export function usePreviewConfig(
7477
7578 hostClient . agent . getPreviewConfigOptions
7679 . query ( { apiHost, adapter } , { signal : abort . signal } )
77- . then ( ( options ) => {
80+ . then ( ( serverOptions ) => {
7881 if ( abort . signal . aborted ) return ;
7982
83+ const options = glmEnabled
84+ ? serverOptions
85+ : serverOptions . map ( stripGlmModelOption ) ;
86+
8087 const {
8188 defaultInitialTaskMode,
8289 lastUsedInitialTaskMode,
@@ -134,7 +141,7 @@ export function usePreviewConfig(
134141 return ( ) => {
135142 abort . abort ( ) ;
136143 } ;
137- } , [ adapter , apiHost , hostClient , hasHydrated ] ) ;
144+ } , [ adapter , apiHost , hostClient , hasHydrated , glmEnabled ] ) ;
138145
139146 const setConfigOption = useCallback (
140147 ( configId : string , value : string ) => {
0 commit comments