Skip to content

A reactive notebook for Python — run reproducible experiments, query with SQL, execute as a script, deploy as an app, and version with git. Stored as pure Python. All in a modern, AI-native editor.

add error banner for acp to save the notebook (#7470)

Shahmir Varqhad545d6491283
diff --git a/frontend/src/components/chat/acp/agent-panel.tsx b/frontend/src/components/chat/acp/agent-panel.tsx
index e212d725ae..7a6d544a2e 100644
--- a/frontend/src/components/chat/acp/agent-panel.tsx
+++ b/frontend/src/components/chat/acp/agent-panel.tsx
@@ -67,6 +67,7 @@ import { DelayMount } from "@/components/utils/delay-mount";
import { useRequestClient } from "@/core/network/requests";
import { filenameAtom } from "@/core/saving/file-state";
import { store } from "@/core/state/jotai";
+import { ErrorBanner } from "@/plugins/impl/common/error-banner";
import { Functions } from "@/utils/functions";
import { Paths } from "@/utils/paths";
import { FileAttachmentPill } from "../chat-components";
@@ -652,13 +653,16 @@ const NO_WS_SET = "_skip_auto_connect_";
function getCwd() {
const filename = store.get(filenameAtom);
if (!filename) {
- return "";
+ throw new Error(
+ "Please save the notebook and refresh the browser to use the agent",
+ );
}
return Paths.dirname(filename);
}
const AgentPanel: React.FC = () => {
const [isLoading, setIsLoading] = useState(false);
+ const [error, setError] = useState<Error | string | null>(null);
const [promptValue, setPromptValue] = useState("");
const [files, setFiles] = useState<File[]>();
const [sessionModels, setSessionModels] = useState<SessionModelState | null>(
@@ -851,8 +855,10 @@ const AgentPanel: React.FC = () => {
} else {
await handleNewSession();
}
+ setError(null);
} catch (error) {
logger.error("Failed to create or resume session:", error);
+ setError(error instanceof Error ? error : String(error));
}
};
@@ -1049,6 +1055,24 @@ const AgentPanel: React.FC = () => {
}
const renderBody = () => {
+ if (error) {
+ return (
+ <ErrorBanner
+ className="w-3/4 mx-auto mt-10"
+ error={error}
+ action={
+ <Button
+ variant="linkDestructive"
+ size="sm"
+ onClick={() => setError(null)}
+ >
+ Dismiss
+ </Button>
+ }
+ />
+ );
+ }
+
const isConnecting = connectionState.status === "connecting";
const delay = 200; // ms
if (isConnecting) {