Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion app/api/agent/stream/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,11 @@ function sseComment(comment: string): Uint8Array {

export async function GET(request: Request) {
const { searchParams } = new URL(request.url);
const [sessionId, goal] = [searchParams.get("sessionId"), searchParams.get("goal")];
const [sessionId, goal, fromChat] = [
searchParams.get("sessionId"),
searchParams.get("goal"),
searchParams.get("fromChat") === "true"
];

if (!sessionId || !goal) {
return new Response(
Expand Down Expand Up @@ -118,6 +122,7 @@ export async function GET(request: Request) {
width: 1288,
height: 711,
},
solveCaptchas: !fromChat, // false if session is from a search param, true otherwise
},
},
useAPI: false,
Expand Down
4 changes: 3 additions & 1 deletion app/components/BrowserSessionContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ interface BrowserSessionContainerProps {
isCompleted: boolean;
initialMessage: string | undefined;
sessionTime?: number;
isFromSearchParam?: boolean;
onStop?: () => void;
onRestart?: () => void;
}
Expand Down Expand Up @@ -104,6 +105,7 @@ const BrowserSessionContainer: React.FC<BrowserSessionContainerProps> = ({
isCompleted,
initialMessage,
sessionTime = 0,
isFromSearchParam = false,
onStop = () => {},
onRestart = () => {},
}) => {
Expand Down Expand Up @@ -192,7 +194,7 @@ const BrowserSessionContainer: React.FC<BrowserSessionContainerProps> = ({
sessionUrl ? (
<iframe
src={sessionUrl}
className="w-full h-full border-none pointer-events-none"
className={`w-full h-full border-none ${!isFromSearchParam ? 'pointer-events-none' : ''}`}
sandbox="allow-same-origin allow-scripts allow-forms"
allow="clipboard-read; clipboard-write"
loading="lazy"
Expand Down
3 changes: 3 additions & 0 deletions app/components/ChatFeed.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import { ChatFeedProps, AgentState, BrowserStep } from "../types/ChatFeed";

export default function ChatFeed({
initialMessage,
isFromSearchParam = false,
onClose,
}: ChatFeedProps) {
const renderCount = useRef(0);
Expand Down Expand Up @@ -199,6 +200,7 @@ export default function ChatFeed({
} = useAgentStream({
sessionId: null,
goal: initialMessage,
isFromSearchParam,
onStart: handleStart,
onDone: handleDone,
onError: handleError,
Expand Down Expand Up @@ -297,6 +299,7 @@ export default function ChatFeed({
isCompleted={agentFinished}
initialMessage={initialMessage || undefined}
sessionTime={sessionTime}
isFromSearchParam={isFromSearchParam}
onStop={handleDone}
onRestart={onClose}
/>
Expand Down
4 changes: 3 additions & 1 deletion app/hooks/useAgentStream.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ const sessionCreationPromises = new Map<
export function useAgentStream({
sessionId,
goal,
isFromSearchParam = false,
onStart,
onDone,
onError,
Expand Down Expand Up @@ -162,6 +163,7 @@ export function useAgentStream({
const params = new URLSearchParams({
sessionId: currentSessionId!,
goal,
fromChat: String(isFromSearchParam),
});

const es = new EventSource(`/api/agent/stream?${params.toString()}`);
Expand Down Expand Up @@ -387,7 +389,7 @@ export function useAgentStream({
eventSourceRef.current.close();
}
};
}, [sessionId, goal, parseLog, isEmptyObject]);
}, [sessionId, goal, parseLog, isEmptyObject, isFromSearchParam]);

return {
...state,
Expand Down
1 change: 1 addition & 0 deletions app/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,7 @@ export default function Home() {
<ChatFeed
key={`chat-feed-${initialMessage}`}
initialMessage={initialMessage}
isFromSearchParam={!!chatParam}
onClose={() => setIsChatVisible(false)}
/>
)}
Expand Down
1 change: 1 addition & 0 deletions app/types/Agent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ export interface DoneEventData {
export interface UseAgentStreamProps {
sessionId: string | null;
goal: string | null;
isFromSearchParam?: boolean;
onStart?: (data: StartEventData) => void;
onDone?: (data?: DoneEventData) => void;
onError?: (error: string) => void;
Expand Down
1 change: 1 addition & 0 deletions app/types/ChatFeed.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
export interface ChatFeedProps {
initialMessage: string | null;
isFromSearchParam?: boolean;
onClose: () => void;
url?: string;
}
Expand Down