From e27ee0041e817318a57222c524a7d567769a72d9 Mon Sep 17 00:00:00 2001 From: Eric Allam Date: Wed, 12 Nov 2025 15:51:11 +0000 Subject: [PATCH] fix(streams): fixed broken wrapping in streams inspector --- .../route.tsx | 18 ++++++++++-------- references/realtime-streams/src/app/actions.ts | 10 ++++++---- .../src/app/runs/[runId]/page.tsx | 5 +++-- .../src/components/streams.tsx | 14 +++++++++++--- 4 files changed, 30 insertions(+), 17 deletions(-) diff --git a/apps/webapp/app/routes/resources.orgs.$organizationSlug.projects.$projectParam.env.$envParam.runs.$runParam.streams.$streamKey/route.tsx b/apps/webapp/app/routes/resources.orgs.$organizationSlug.projects.$projectParam.env.$envParam.runs.$runParam.streams.$streamKey/route.tsx index b508a4a353..a1d9415970 100644 --- a/apps/webapp/app/routes/resources.orgs.$organizationSlug.projects.$projectParam.env.$envParam.runs.$runParam.streams.$streamKey/route.tsx +++ b/apps/webapp/app/routes/resources.orgs.$organizationSlug.projects.$projectParam.env.$envParam.runs.$runParam.streams.$streamKey/route.tsx @@ -199,8 +199,11 @@ export function RealtimeStreamViewer({ // Auto-scroll to bottom when new chunks arrive, if we're at the bottom useEffect(() => { - if (isAtBottom && bottomRef.current) { - bottomRef.current.scrollIntoView({ behavior: "instant", block: "end" }); + if (isAtBottom && scrollRef.current) { + // Preserve horizontal scroll position while scrolling to bottom vertically + const currentScrollLeft = scrollRef.current.scrollLeft; + scrollRef.current.scrollTop = scrollRef.current.scrollHeight; + scrollRef.current.scrollLeft = currentScrollLeft; } }, [chunks, isAtBottom]); @@ -340,7 +343,7 @@ export function RealtimeStreamViewer({ {/* Content */}
{error && (
@@ -372,8 +375,8 @@ export function RealtimeStreamViewer({
{rowVirtualizer.getVirtualItems().map((virtualItem) => ( @@ -452,12 +455,11 @@ function StreamChunkLine({ return (
{/* Timestamp */} -
{timestamp}
+
{timestamp}
{/* Content */} -
{formattedData}
+
{formattedData}
); } diff --git a/references/realtime-streams/src/app/actions.ts b/references/realtime-streams/src/app/actions.ts index acfab7b57a..ae2794abb5 100644 --- a/references/realtime-streams/src/app/actions.ts +++ b/references/realtime-streams/src/app/actions.ts @@ -31,12 +31,14 @@ export async function triggerStreamTask( } ); - console.log("Triggered run:", handle.id); - // Redirect to custom path or default run page const path = redirectPath - ? `${redirectPath}/${handle.id}?accessToken=${handle.publicAccessToken}` - : `/runs/${handle.id}?accessToken=${handle.publicAccessToken}`; + ? `${redirectPath}/${handle.id}?accessToken=${handle.publicAccessToken}&isMarkdown=${ + scenario === "markdown" ? "true" : "false" + }` + : `/runs/${handle.id}?accessToken=${handle.publicAccessToken}&isMarkdown=${ + scenario === "markdown" ? "true" : "false" + }`; redirect(path); } diff --git a/references/realtime-streams/src/app/runs/[runId]/page.tsx b/references/realtime-streams/src/app/runs/[runId]/page.tsx index f67bcc77f8..54854dfe75 100644 --- a/references/realtime-streams/src/app/runs/[runId]/page.tsx +++ b/references/realtime-streams/src/app/runs/[runId]/page.tsx @@ -6,10 +6,11 @@ export default function RunPage({ searchParams, }: { params: { runId: string }; - searchParams: { accessToken?: string }; + searchParams: { accessToken?: string; isMarkdown?: string }; }) { const { runId } = params; const accessToken = searchParams.accessToken; + const isMarkdown = searchParams.isMarkdown === "true"; if (!accessToken) { return ( @@ -49,7 +50,7 @@ export default function RunPage({
- +
diff --git a/references/realtime-streams/src/components/streams.tsx b/references/realtime-streams/src/components/streams.tsx index 5419dc314e..131c430a15 100644 --- a/references/realtime-streams/src/components/streams.tsx +++ b/references/realtime-streams/src/components/streams.tsx @@ -4,12 +4,20 @@ import { useRealtimeStream } from "@trigger.dev/react-hooks"; import { Streamdown } from "streamdown"; import { demoStream } from "@/app/streams"; -export function Streams({ accessToken, runId }: { accessToken: string; runId: string }) { +export function Streams({ + accessToken, + runId, + isMarkdown, +}: { + accessToken: string; + runId: string; + isMarkdown: boolean; +}) { const { parts, error } = useRealtimeStream(demoStream, runId, { accessToken, baseURL: process.env.NEXT_PUBLIC_TRIGGER_API_URL, onData: (data) => { - console.log(data); + // console.log(data); }, timeoutInSeconds: 600, }); @@ -26,7 +34,7 @@ export function Streams({ accessToken, runId }: { accessToken: string; runId: st Run: {runId}
- {stream} + {isMarkdown ? {stream} : stream}
);