@@ -16,7 +16,9 @@ const mockRunData = {
1616// Simulate 5-second loading delay to test skeleton
1717const LOADING_DELAY_MS = 2000 ;
1818
19- // Set up mock window.openai for local development
19+ // Set up mock window.openai for local development (no-ops when window.openai already exists)
20+ const isMockEnvironment = typeof window !== "undefined" && ! window . openai ;
21+
2022setupMockOpenAi ( {
2123 toolOutput : mockRunData , // Start with basic data (no dataset) to show header immediately
2224 initialWidgetState : {
@@ -191,69 +193,71 @@ setupMockOpenAi({
191193 } ,
192194} ) ;
193195
194- // Simulate loading delay - update toolOutput after 5 seconds to add dataset
195- setTimeout ( ( ) => {
196- if ( window . openai ) {
197- // Update the toolOutput with dataset to show results
198- window . openai . toolOutput = {
199- ...mockRunData ,
200- status : "SUCCEEDED" ,
201- finishedAt : new Date ( ) . toISOString ( ) ,
202- dataset : {
203- datasetId : "test_dataset_456" ,
204- itemCount : 15 ,
205- previewItems : [
206- {
207- title : "Example Page 1" ,
208- url : "https://example.com/page-1" ,
209- description : "This is a long description that should test text overflow and ellipsis in table cells" ,
210- category : "Technology" ,
211- price : "$29.99" ,
212- rating : "4.5/5" ,
213- date : "2026-02-10"
214- } ,
215- {
216- title : "Example Page 2" ,
217- url : "https://example.com/page-2" ,
218- description : "Another lengthy description to ensure we can test horizontal scrolling properly" ,
219- category : "Business" ,
220- price : "$49.99" ,
221- rating : "4.8/5" ,
222- date : "2026-02-09"
223- } ,
224- {
225- title : "Example Page 3" ,
226- url : "https://example.com/page-3" ,
227- description : "Third item with even more text content for testing purposes" ,
228- category : "Science" ,
229- price : "$39.99" ,
230- rating : "4.2/5" ,
231- date : "2026-02-08"
232- } ,
233- {
234- title : "Example Page 4" ,
235- url : "https://example.com/page-4" ,
236- description : "Fourth item in the dataset to test vertical scrolling" ,
237- category : "Health" ,
238- price : "$19.99" ,
239- rating : "4.7/5" ,
240- date : "2026-02-07"
241- } ,
242- {
243- title : "Example Page 5" ,
244- url : "https://example.com/page-5" ,
245- description : "Fifth item with more content to fill the table" ,
246- category : "Education" ,
247- price : "$59.99" ,
248- rating : "4.9/5" ,
249- date : "2026-02-06"
250- } ,
251- ] ,
252- } ,
253- } as any ;
254- // Trigger a re-render by dispatching an event
255- window . dispatchEvent ( new Event ( 'openai:set_globals' ) ) ;
256- }
257- } , LOADING_DELAY_MS ) ;
196+ // Simulate loading delay - update toolOutput after delay to add dataset (only in local dev)
197+ if ( isMockEnvironment ) {
198+ setTimeout ( ( ) => {
199+ if ( window . openai ) {
200+ // Update the toolOutput with dataset to show results
201+ window . openai . toolOutput = {
202+ ...mockRunData ,
203+ status : "SUCCEEDED" ,
204+ finishedAt : new Date ( ) . toISOString ( ) ,
205+ dataset : {
206+ datasetId : "test_dataset_456" ,
207+ itemCount : 15 ,
208+ previewItems : [
209+ {
210+ title : "Example Page 1" ,
211+ url : "https://example.com/page-1" ,
212+ description : "This is a long description that should test text overflow and ellipsis in table cells" ,
213+ category : "Technology" ,
214+ price : "$29.99" ,
215+ rating : "4.5/5" ,
216+ date : "2026-02-10"
217+ } ,
218+ {
219+ title : "Example Page 2" ,
220+ url : "https://example.com/page-2" ,
221+ description : "Another lengthy description to ensure we can test horizontal scrolling properly" ,
222+ category : "Business" ,
223+ price : "$49.99" ,
224+ rating : "4.8/5" ,
225+ date : "2026-02-09"
226+ } ,
227+ {
228+ title : "Example Page 3" ,
229+ url : "https://example.com/page-3" ,
230+ description : "Third item with even more text content for testing purposes" ,
231+ category : "Science" ,
232+ price : "$39.99" ,
233+ rating : "4.2/5" ,
234+ date : "2026-02-08"
235+ } ,
236+ {
237+ title : "Example Page 4" ,
238+ url : "https://example.com/page-4" ,
239+ description : "Fourth item in the dataset to test vertical scrolling" ,
240+ category : "Health" ,
241+ price : "$19.99" ,
242+ rating : "4.7/5" ,
243+ date : "2026-02-07"
244+ } ,
245+ {
246+ title : "Example Page 5" ,
247+ url : "https://example.com/page-5" ,
248+ description : "Fifth item with more content to fill the table" ,
249+ category : "Education" ,
250+ price : "$59.99" ,
251+ rating : "4.9/5" ,
252+ date : "2026-02-06"
253+ } ,
254+ ] ,
255+ } ,
256+ } as any ;
257+ // Trigger a re-render by dispatching an event
258+ window . dispatchEvent ( new Event ( 'openai:set_globals' ) ) ;
259+ }
260+ } , LOADING_DELAY_MS ) ;
261+ }
258262
259263renderWidget ( ActorRun ) ;
0 commit comments