mirror of
https://github.com/harivansh-afk/sandbox-agent.git
synced 2026-04-15 09:01:17 +00:00
feat: add end session button to chat header
This commit is contained in:
parent
53a06becb1
commit
962512a0db
3 changed files with 29 additions and 1 deletions
|
|
@ -548,6 +548,16 @@ export default function App() {
|
|||
}
|
||||
};
|
||||
|
||||
const endSession = async () => {
|
||||
if (!sessionId) return;
|
||||
try {
|
||||
await getClient().terminateSession(sessionId);
|
||||
await fetchSessions();
|
||||
} catch (error) {
|
||||
setSessionError(getErrorMessage(error, "Unable to end session"));
|
||||
}
|
||||
};
|
||||
|
||||
const questionRequests = useMemo(() => {
|
||||
const latestById = new Map<string, QuestionEventData>();
|
||||
for (const event of events) {
|
||||
|
|
@ -859,6 +869,7 @@ export default function App() {
|
|||
onVariantChange={setVariant}
|
||||
onStreamModeChange={setStreamMode}
|
||||
onToggleStream={toggleStream}
|
||||
onEndSession={endSession}
|
||||
hasSession={Boolean(sessionId)}
|
||||
eventError={eventError}
|
||||
questionRequests={questionRequests}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import { MessageSquare, PauseCircle, PlayCircle, Plus, Terminal } from "lucide-react";
|
||||
import { MessageSquare, PauseCircle, PlayCircle, Plus, Square, Terminal } from "lucide-react";
|
||||
import { useEffect, useRef, useState } from "react";
|
||||
import type { AgentInfo, AgentModeInfo, PermissionEventData, QuestionEventData } from "sandbox-agent";
|
||||
import ApprovalsTab from "../debug/ApprovalsTab";
|
||||
|
|
@ -39,6 +39,7 @@ const ChatPanel = ({
|
|||
onVariantChange,
|
||||
onStreamModeChange,
|
||||
onToggleStream,
|
||||
onEndSession,
|
||||
eventError,
|
||||
questionRequests,
|
||||
permissionRequests,
|
||||
|
|
@ -79,6 +80,7 @@ const ChatPanel = ({
|
|||
onVariantChange: (value: string) => void;
|
||||
onStreamModeChange: (value: "poll" | "sse" | "turn") => void;
|
||||
onToggleStream: () => void;
|
||||
onEndSession: () => void;
|
||||
eventError: string | null;
|
||||
questionRequests: QuestionEventData[];
|
||||
permissionRequests: PermissionEventData[];
|
||||
|
|
@ -131,6 +133,17 @@ const ChatPanel = ({
|
|||
)}
|
||||
</div>
|
||||
<div className="panel-header-right">
|
||||
{sessionId && (
|
||||
<button
|
||||
type="button"
|
||||
className="button ghost small"
|
||||
onClick={onEndSession}
|
||||
title="End session"
|
||||
>
|
||||
<Square size={12} />
|
||||
End
|
||||
</button>
|
||||
)}
|
||||
<div className="setup-stream">
|
||||
<select
|
||||
className="setup-select-small"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue