Merge branch 'dev' into swiftyos/sdk

This commit is contained in:
Swifty
2025-07-07 15:54:04 +02:00
committed by GitHub
5 changed files with 38 additions and 23 deletions

View File

@@ -1,4 +1,5 @@
"use client";
import { useParams, useRouter } from "next/navigation";
import React, {
useCallback,
useEffect,
@@ -6,31 +7,31 @@ import React, {
useRef,
useState,
} from "react";
import { useParams, useRouter } from "next/navigation";
import { exportAsJSONFile } from "@/lib/utils";
import { useBackendAPI } from "@/lib/autogpt-server-api/context";
import {
Graph,
GraphExecution,
GraphExecutionID,
GraphExecutionMeta,
Graph,
GraphID,
LibraryAgent,
LibraryAgentID,
Schedule,
ScheduleID,
LibraryAgentPreset,
LibraryAgentPresetID,
Schedule,
ScheduleID,
} from "@/lib/autogpt-server-api";
import { useBackendAPI } from "@/lib/autogpt-server-api/context";
import { exportAsJSONFile } from "@/lib/utils";
import type { ButtonAction } from "@/components/agptui/types";
import DeleteConfirmDialog from "@/components/agptui/delete-confirm-dialog";
import AgentRunDraftView from "@/components/agents/agent-run-draft-view";
import AgentRunDetailsView from "@/components/agents/agent-run-details-view";
import AgentRunDraftView from "@/components/agents/agent-run-draft-view";
import AgentRunsSelectorList from "@/components/agents/agent-runs-selector-list";
import AgentScheduleDetailsView from "@/components/agents/agent-schedule-details-view";
import DeleteConfirmDialog from "@/components/agptui/delete-confirm-dialog";
import type { ButtonAction } from "@/components/agptui/types";
import { useOnboarding } from "@/components/onboarding/onboarding-provider";
import { Button } from "@/components/ui/button";
import {
Dialog,
DialogContent,
@@ -39,9 +40,8 @@ import {
DialogHeader,
DialogTitle,
} from "@/components/ui/dialog";
import { Button } from "@/components/ui/button";
import { useToast } from "@/components/ui/use-toast";
import LoadingBox, { LoadingSpinner } from "@/components/ui/loading";
import { useToast } from "@/components/ui/use-toast";
export default function AgentRunsPage(): React.ReactElement {
const { id: agentID }: { id: LibraryAgentID } = useParams();
@@ -434,6 +434,9 @@ export default function AgentRunsPage(): React.ReactElement {
[agent, downloadGraph],
);
const runGraph =
graphVersions.current[selectedRun?.graph_version ?? 0] ?? graph;
const onCreateSchedule = useCallback(
(schedule: Schedule) => {
setSchedules((prev) => [...prev, schedule]);
@@ -496,16 +499,16 @@ export default function AgentRunsPage(): React.ReactElement {
{/* Run / Schedule views */}
{(selectedView.type == "run" && selectedView.id ? (
selectedRun && (
selectedRun && runGraph ? (
<AgentRunDetailsView
agent={agent}
graph={graphVersions.current[selectedRun.graph_version] ?? graph}
graph={runGraph}
run={selectedRun}
agentActions={agentActions}
onRun={selectRun}
deleteRun={() => setConfirmingDeleteAgentRun(selectedRun)}
/>
)
) : null
) : selectedView.type == "run" ? (
/* Draft new runs / Create new presets */
<AgentRunDraftView
@@ -529,7 +532,8 @@ export default function AgentRunsPage(): React.ReactElement {
agentActions={agentActions}
/>
) : selectedView.type == "schedule" ? (
selectedSchedule && (
selectedSchedule &&
graph && (
<AgentScheduleDetailsView
graph={graph}
schedule={selectedSchedule}

View File

@@ -86,7 +86,7 @@ function createUnsupportedContentTypeResponse(
"application/x-www-form-urlencoded",
],
},
{ status: 415 }, // Unsupported Media Type
{ status: 415 },
);
}
@@ -110,9 +110,19 @@ function createErrorResponse(error: unknown): NextResponse {
// If it's our custom ApiError, preserve the original status and response
if (error instanceof ApiError) {
return NextResponse.json(error.response || { error: error.message }, {
status: error.status,
});
}
// For JSON parsing errors, provide more context
if (error instanceof SyntaxError && error.message.includes("JSON")) {
return NextResponse.json(
error.response || { error: error.message, detail: error.message },
{ status: error.status },
{
error: "Invalid response from backend",
detail: error.message ?? "Backend returned non-JSON response",
},
{ status: 502 },
);
}
@@ -121,7 +131,7 @@ function createErrorResponse(error: unknown): NextResponse {
error instanceof Error ? error.message : "An unknown error occurred";
return NextResponse.json(
{ error: "Proxy request failed", detail },
{ status: 500 }, // Internal Server Error
{ status: 500 },
);
}

View File

@@ -242,7 +242,7 @@ export default function AgentRunDetailsView({
</label>
{values.map((value, i) => (
<p
className="resize-none whitespace-pre-wrap break-words border-none text-sm text-neutral-700 disabled:cursor-not-allowed"
className="resize-none overflow-x-auto whitespace-pre-wrap break-words border-none text-sm text-neutral-700 disabled:cursor-not-allowed"
key={i}
>
{value}

View File

@@ -197,9 +197,10 @@ function useToastOnFail() {
return React.useCallback(
(action: string, { rethrow = false }: ToastOnFailOptions = {}) =>
(error: any) => {
const err = error as Error;
toast({
title: `Unable to ${action}`,
description: (error as Error)?.message ?? "Something went wrong",
description: err.message ?? "Something went wrong",
variant: "destructive",
duration: 10000,
});
@@ -211,4 +212,4 @@ function useToastOnFail() {
);
}
export { useToast, toast, useToastOnFail };
export { toast, useToast, useToastOnFail };

View File

@@ -78,7 +78,7 @@ export async function getServerAuthToken(): Promise<string> {
error,
} = await supabase.auth.getSession();
if (error || !session?.access_token) {
if (error || !session || !session.access_token) {
return "no-token-found";
}