Skip to content

Commit

Permalink
Close the SSE connection whe stopping the process client side
Browse files Browse the repository at this point in the history
  • Loading branch information
syldium committed Nov 30, 2023
1 parent d78b0f3 commit 093bb80
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion frontend/src/playground.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,15 @@ export function Playground() {
});
};

const handleStopClick = () =>
setSSE((current) => {
if (current) {
current.close();
appendOutputText('Process terminated by user');
}
return null;
});

useEffect(() => {
localStorage.setItem('editorText', editorText);
}, [editorText]);
Expand All @@ -57,7 +66,7 @@ export function Playground() {
<>
<Navbar
isRunning={sse !== null}
onRunClick={handleRunClick}
onRunClick={sse === null ? handleRunClick : handleStopClick}
/>
<Split
class="d-flex"
Expand Down

0 comments on commit 093bb80

Please sign in to comment.