File tree Expand file tree Collapse file tree 3 files changed +11
-2
lines changed
Expand file tree Collapse file tree 3 files changed +11
-2
lines changed Original file line number Diff line number Diff line change @@ -5,7 +5,7 @@ import { getAdsEnabled } from '../commands/ads'
55import { useChatStore } from '../state/chat-store'
66import { subscribeToActivity } from '../utils/activity-tracker'
77import { getAuthToken } from '../utils/auth'
8- import { logger , loggerContext } from '../utils/logger'
8+ import { logger } from '../utils/logger'
99
1010const AD_ROTATION_INTERVAL_MS = 60 * 1000 // 60 seconds per ad
1111const MAX_ADS_AFTER_ACTIVITY = 3 // Show up to 3 ads after last activity, then stop
@@ -155,7 +155,7 @@ export const useGravityAd = (): GravityAdState => {
155155 } ,
156156 body : JSON . stringify ( {
157157 messages : adMessages ,
158- sessionId : loggerContext . clientSessionId ,
158+ sessionId : useChatStore . getState ( ) . chatSessionId ,
159159 device : getDeviceInfo ( ) ,
160160 } ) ,
161161 } )
Original file line number Diff line number Diff line change @@ -95,6 +95,8 @@ export type SuggestedFollowupsState = {
9595export type ClickedFollowupsMap = Map < string , Set < number > >
9696
9797export type ChatStoreState = {
98+ /** Unique ID for this chat session, regenerated on /new */
99+ chatSessionId : string
98100 messages : ChatMessage [ ]
99101 streamingAgents : Set < string >
100102 focusedAgentId : string | null
@@ -204,7 +206,10 @@ type ChatStoreActions = {
204206
205207type ChatStore = ChatStoreState & ChatStoreActions
206208
209+ const generateSessionId = ( ) => crypto . randomUUID ( )
210+
207211const initialState : ChatStoreState = {
212+ chatSessionId : generateSessionId ( ) ,
208213 messages : [ ] ,
209214 streamingAgents : new Set < string > ( ) ,
210215 focusedAgentId : null ,
@@ -466,6 +471,7 @@ export const useChatStore = create<ChatStore>()(
466471
467472 reset : ( ) =>
468473 set ( ( state ) => {
474+ state . chatSessionId = generateSessionId ( )
469475 state . messages = initialState . messages . slice ( )
470476 state . streamingAgents = new Set ( initialState . streamingAgents )
471477 state . focusedAgentId = initialState . focusedAgentId
Original file line number Diff line number Diff line change @@ -152,9 +152,12 @@ export async function postAds(params: {
152152 renderContext : {
153153 placements : [ { placement : 'below_response' } ] ,
154154 max_ad_length : 200 ,
155+ supports_links : true ,
156+ supports_markdown : false ,
155157 } ,
156158 ...( device ? { device } : { } ) ,
157159 testAd : serverEnv . CB_ENVIRONMENT !== 'prod' ,
160+ numAds : 1 ,
158161 }
159162 // Call Gravity API
160163 const response = await fetch ( 'https://server.trygravity.ai/ad' , {
You can’t perform that action at this time.
0 commit comments