@@ -3,7 +3,12 @@ import {
33 followLinkedThread ,
44 type LinkedThreadView as LinkedThreadState ,
55} from "@t3tools/client-runtime/linked-thread" ;
6- import { EnvironmentId , type OrchestrationV2ThreadHistoryPage } from "@t3tools/contracts" ;
6+ import {
7+ EnvironmentId ,
8+ TurnItemId ,
9+ type OrchestrationV2ThreadHistoryPage ,
10+ } from "@t3tools/contracts" ;
11+ import * as DateTime from "effect/DateTime" ;
712import * as Effect from "effect/Effect" ;
813import * as Queue from "effect/Queue" ;
914import * as Stream from "effect/Stream" ;
@@ -25,7 +30,11 @@ vi.mock("react-native", () => {
2530 return {
2631 AppState : { currentState : "active" , addEventListener : ( ) => ( { remove ( ) { } } ) } ,
2732 Platform : { OS : "android" } ,
28- Pressable : Container ,
33+ Pressable : ( { children, onPress } : { children : ReactNode ; onPress ?: ( ) => void } ) => (
34+ < div data-pressable onClick = { onPress } >
35+ { children }
36+ </ div >
37+ ) ,
2938 ScrollView : Container ,
3039 Text : Container ,
3140 View : Container ,
@@ -132,3 +141,78 @@ it.effect(
132141 }
133142 } ) . pipe ( Effect . scoped ) ,
134143) ;
144+
145+ it ( "shows a linked file search's pattern, not its raw item JSON, like the thread screen" , ( ) => {
146+ vi . stubGlobal ( "IS_REACT_ACT_ENVIRONMENT" , true ) ;
147+ const container = document . createElement ( "div" ) ;
148+ const root = createRoot ( container ) ;
149+ const now = DateTime . makeUnsafe ( "2026-11-29T00:00:00Z" ) ;
150+ const itemId = TurnItemId . make ( "linked-search" ) ;
151+ const threadId = v2Projection . thread . id ;
152+ const projection = {
153+ ...v2Projection ,
154+ visibleTurnItems : [
155+ {
156+ position : 0 ,
157+ visibility : "local" ,
158+ sourceThreadId : threadId ,
159+ sourceItemId : itemId ,
160+ item : {
161+ id : itemId ,
162+ threadId,
163+ runId : null ,
164+ nodeId : null ,
165+ providerThreadId : null ,
166+ providerTurnId : null ,
167+ nativeItemRef : null ,
168+ parentItemId : null ,
169+ ordinal : 1 ,
170+ status : "completed" ,
171+ title : null ,
172+ startedAt : now ,
173+ completedAt : now ,
174+ updatedAt : now ,
175+ type : "file_search" ,
176+ pattern : "TODO" ,
177+ results : [ { fileName : "src/app.ts" , line : 3 , preview : "// TODO tidy" } ] ,
178+ } ,
179+ } ,
180+ ] ,
181+ } as typeof v2Projection ;
182+ vi . mocked ( useLinkedThreadView ) . mockReturnValue ( {
183+ view : {
184+ thread : { projection, historyCursor : null } ,
185+ error : null ,
186+ history : { loading : false , failed : false } ,
187+ loadedHistory : null ,
188+ loadEarlier ( ) { } ,
189+ } as unknown as LinkedThreadState ,
190+ error : null ,
191+ retry ( ) { } ,
192+ } ) ;
193+ try {
194+ act ( ( ) =>
195+ root . render (
196+ < LinkedThreadView
197+ target = { {
198+ viaEnvironmentId : EnvironmentId . make ( "via" ) ,
199+ environmentId : EnvironmentId . make ( "linked" ) ,
200+ threadId,
201+ label : "Linked test environment" ,
202+ title : null ,
203+ } }
204+ /> ,
205+ ) ,
206+ ) ;
207+ const row = [ ...container . querySelectorAll < HTMLElement > ( "[data-pressable]" ) ] . find ( ( element ) =>
208+ element . textContent ?. includes ( "TODO" ) ,
209+ ) ! ;
210+ act ( ( ) => row . click ( ) ) ;
211+ expect ( row . textContent ) . toContain ( "pattern: TODO" ) ;
212+ expect ( row . textContent ) . toContain ( "3: // TODO tidy" ) ;
213+ expect ( row . textContent ) . not . toContain ( "sourceItemId" ) ;
214+ } finally {
215+ act ( ( ) => root . unmount ( ) ) ;
216+ vi . unstubAllGlobals ( ) ;
217+ }
218+ } ) ;
0 commit comments