Skip to content

Commit a70ab10

Browse files
authored
fix(streams): fixed broken wrapping in streams inspector (#2672)
1 parent f7cb637 commit a70ab10

File tree

4 files changed

+30
-17
lines changed
  • apps/webapp/app/routes/resources.orgs.$organizationSlug.projects.$projectParam.env.$envParam.runs.$runParam.streams.$streamKey
  • references/realtime-streams/src

4 files changed

+30
-17
lines changed

apps/webapp/app/routes/resources.orgs.$organizationSlug.projects.$projectParam.env.$envParam.runs.$runParam.streams.$streamKey/route.tsx

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -199,8 +199,11 @@ export function RealtimeStreamViewer({
199199

200200
// Auto-scroll to bottom when new chunks arrive, if we're at the bottom
201201
useEffect(() => {
202-
if (isAtBottom && bottomRef.current) {
203-
bottomRef.current.scrollIntoView({ behavior: "instant", block: "end" });
202+
if (isAtBottom && scrollRef.current) {
203+
// Preserve horizontal scroll position while scrolling to bottom vertically
204+
const currentScrollLeft = scrollRef.current.scrollLeft;
205+
scrollRef.current.scrollTop = scrollRef.current.scrollHeight;
206+
scrollRef.current.scrollLeft = currentScrollLeft;
204207
}
205208
}, [chunks, isAtBottom]);
206209

@@ -340,7 +343,7 @@ export function RealtimeStreamViewer({
340343
{/* Content */}
341344
<div
342345
ref={scrollRef}
343-
className="flex-1 overflow-y-auto bg-charcoal-900 scrollbar-thin scrollbar-track-transparent scrollbar-thumb-charcoal-600"
346+
className="flex-1 overflow-x-auto overflow-y-auto bg-charcoal-900 scrollbar-thin scrollbar-track-transparent scrollbar-thumb-charcoal-600"
344347
>
345348
{error && (
346349
<div className="border-b border-error/20 bg-error/10 p-3">
@@ -372,8 +375,8 @@ export function RealtimeStreamViewer({
372375
<div
373376
style={{
374377
height: `${rowVirtualizer.getTotalSize()}px`,
375-
width: "100%",
376378
position: "relative",
379+
minWidth: "100%",
377380
}}
378381
>
379382
{rowVirtualizer.getVirtualItems().map((virtualItem) => (
@@ -452,12 +455,11 @@ function StreamChunkLine({
452455

453456
return (
454457
<div
455-
className="group flex w-full gap-3 py-1 hover:bg-charcoal-800"
458+
className="group flex gap-3 py-1 hover:bg-charcoal-800"
456459
style={{
457460
position: "absolute",
458461
top: 0,
459462
left: 0,
460-
width: "100%",
461463
height: `${size}px`,
462464
transform: `translateY(${start}px)`,
463465
}}
@@ -471,10 +473,10 @@ function StreamChunkLine({
471473
</div>
472474

473475
{/* Timestamp */}
474-
<div className="flex-none select-none text-charcoal-500">{timestamp}</div>
476+
<div className="flex-none select-none pl-1 text-charcoal-500">{timestamp}</div>
475477

476478
{/* Content */}
477-
<div className="min-w-0 flex-1 break-all text-text-bright">{formattedData}</div>
479+
<div className="whitespace-nowrap text-text-bright">{formattedData}</div>
478480
</div>
479481
);
480482
}

references/realtime-streams/src/app/actions.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,14 @@ export async function triggerStreamTask(
3131
}
3232
);
3333

34-
console.log("Triggered run:", handle.id);
35-
3634
// Redirect to custom path or default run page
3735
const path = redirectPath
38-
? `${redirectPath}/${handle.id}?accessToken=${handle.publicAccessToken}`
39-
: `/runs/${handle.id}?accessToken=${handle.publicAccessToken}`;
36+
? `${redirectPath}/${handle.id}?accessToken=${handle.publicAccessToken}&isMarkdown=${
37+
scenario === "markdown" ? "true" : "false"
38+
}`
39+
: `/runs/${handle.id}?accessToken=${handle.publicAccessToken}&isMarkdown=${
40+
scenario === "markdown" ? "true" : "false"
41+
}`;
4042

4143
redirect(path);
4244
}

references/realtime-streams/src/app/runs/[runId]/page.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,11 @@ export default function RunPage({
66
searchParams,
77
}: {
88
params: { runId: string };
9-
searchParams: { accessToken?: string };
9+
searchParams: { accessToken?: string; isMarkdown?: string };
1010
}) {
1111
const { runId } = params;
1212
const accessToken = searchParams.accessToken;
13+
const isMarkdown = searchParams.isMarkdown === "true";
1314

1415
if (!accessToken) {
1516
return (
@@ -49,7 +50,7 @@ export default function RunPage({
4950
</div>
5051

5152
<div className="w-full border border-gray-200 rounded-lg p-6 bg-white">
52-
<Streams accessToken={accessToken} runId={runId} />
53+
<Streams accessToken={accessToken} runId={runId} isMarkdown={isMarkdown} />
5354
</div>
5455
</main>
5556
</div>

references/realtime-streams/src/components/streams.tsx

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,20 @@ import { useRealtimeStream } from "@trigger.dev/react-hooks";
44
import { Streamdown } from "streamdown";
55
import { demoStream } from "@/app/streams";
66

7-
export function Streams({ accessToken, runId }: { accessToken: string; runId: string }) {
7+
export function Streams({
8+
accessToken,
9+
runId,
10+
isMarkdown,
11+
}: {
12+
accessToken: string;
13+
runId: string;
14+
isMarkdown: boolean;
15+
}) {
816
const { parts, error } = useRealtimeStream(demoStream, runId, {
917
accessToken,
1018
baseURL: process.env.NEXT_PUBLIC_TRIGGER_API_URL,
1119
onData: (data) => {
12-
console.log(data);
20+
// console.log(data);
1321
},
1422
timeoutInSeconds: 600,
1523
});
@@ -26,7 +34,7 @@ export function Streams({ accessToken, runId }: { accessToken: string; runId: st
2634
<span className="font-semibold">Run:</span> {runId}
2735
</div>
2836
<div className="prose prose-sm max-w-none text-gray-900">
29-
<Streamdown isAnimating={true}>{stream}</Streamdown>
37+
{isMarkdown ? <Streamdown isAnimating={true}>{stream}</Streamdown> : stream}
3038
</div>
3139
</div>
3240
);

0 commit comments

Comments
 (0)