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
18 changes: 5 additions & 13 deletions apps/array/src/renderer/features/logs/components/LogView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ import {
} from "@phosphor-icons/react";
import {
Box,
Button,
Code,
ContextMenu,
Flex,
IconButton,
Spinner,
Text,
TextArea,
Tooltip,
Expand All @@ -25,7 +25,6 @@ interface LogViewProps {
isPromptPending?: boolean;
onSendPrompt?: (text: string) => Promise<void>;
onCancelPrompt?: () => void;
onStartSession?: () => void;
}

function renderNotification(notification: SessionNotification): string {
Expand Down Expand Up @@ -61,7 +60,6 @@ export function LogView({
isPromptPending = false,
onSendPrompt,
onCancelPrompt,
onStartSession,
}: LogViewProps) {
const [inputValue, setInputValue] = useState("");
const [showRawLogs, setShowRawLogs] = useState(false);
Expand Down Expand Up @@ -133,24 +131,18 @@ export function LogView({
}
}

// Show start session prompt when no session
// Show initializing state when no session yet
if (!sessionId && !isRunning) {
return (
<Flex
direction="column"
align="center"
justify="center"
height="100%"
p="8"
gap="3"
>
<Flex direction="column" align="center" gap="4">
<Text color="gray">No active session</Text>
{onStartSession && (
<Button size="2" onClick={onStartSession}>
Start Agent Session
</Button>
)}
</Flex>
<Spinner size="3" />
<Text color="gray">Initializing session...</Text>
</Flex>
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,37 +32,35 @@ export function TaskLogsPanel({ taskId, task }: TaskLogsPanelProps) {
const isRunning =
session?.status === "connected" || session?.status === "connecting";

// Auto-reconnect on mount if there's a previous run
// Auto-connect on mount
const hasAttemptedConnect = useRef(false);
useEffect(() => {
if (hasAttemptedConnect.current) return;
if (!repoPath) return;
if (session) return; // Already have a session
if (!task.latest_run?.id || !task.latest_run?.log_url) return;
if (session) return;

hasAttemptedConnect.current = true;

connectToTask({
taskId: task.id,
repoPath,
latestRunId: task.latest_run.id,
latestRunLogUrl: task.latest_run.log_url,
});
}, [task.id, task.latest_run, repoPath, session, connectToTask]);

const handleStartSession = useCallback(async () => {
if (!repoPath) {
log.error("No repo path available");
return;
}
const isNewSession = !task.latest_run?.id;

await connectToTask({
connectToTask({
taskId: task.id,
repoPath,
latestRunId: task.latest_run?.id,
latestRunLogUrl: task.latest_run?.log_url,
initialPrompt:
isNewSession && task.description
? [{ type: "text", text: task.description }]
: undefined,
});
}, [repoPath, task.id, task.latest_run, connectToTask]);
}, [
task.id,
task.description,
task.latest_run,
repoPath,
session,
connectToTask,
]);

const handleSendPrompt = useCallback(
async (text: string) => {
Expand Down Expand Up @@ -91,7 +89,6 @@ export function TaskLogsPanel({ taskId, task }: TaskLogsPanelProps) {
isPromptPending={session?.isPromptPending}
onSendPrompt={handleSendPrompt}
onCancelPrompt={handleCancelPrompt}
onStartSession={handleStartSession}
/>
</Box>
</BackgroundWrapper>
Expand Down