Skip to content

Commit d962b44

Browse files
fix(mobile): linked thread search rows show what was searched instead of raw JSON (#45285)
Co-authored-by: Julius Marminge <julius0216@outlook.com>
1 parent 939b0f9 commit d962b44

2 files changed

Lines changed: 91 additions & 3 deletions

File tree

‎apps/mobile/src/features/threads/LinkedThreadSheet.test.tsx‎

Lines changed: 86 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -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";
712
import * as Effect from "effect/Effect";
813
import * as Queue from "effect/Queue";
914
import * 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+
});

‎apps/mobile/src/features/threads/LinkedThreadSheet.tsx‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,11 @@ function ActivityRow(props: {
7676
? toolCallLines({ command: shownItem.input })
7777
: shownItem.type === "dynamic_tool"
7878
? toolCallLines({ args: shownItem.input })
79-
: null;
79+
: shownItem.type === "file_search"
80+
? toolCallLines({ args: { pattern: shownItem.pattern } })
81+
: shownItem.type === "web_search"
82+
? toolCallLines({ args: { query: shownItem.patterns?.join(", ") } })
83+
: null;
8084
const callText = call
8185
? (call.command ??
8286
call.args?.map(([key, value]) => `${key}: ${value}`).join("\n") ??

0 commit comments

Comments
 (0)