-
Notifications
You must be signed in to change notification settings - Fork 80
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[editor] Server Status Heartbeat (#762)
[editor] Server Status Heartbeat # [editor] Server Status Heartbeat Implement a `server_status` endpoint to use as a heartbeat for the client to know if the server is down; if the request fails, we'll show an error banner at the top of the config to warn the user that the server's in a bad state & some remediation steps (copy important work & restart editor) <img width="1053" alt="Screenshot 2024-01-04 at 6 58 48 PM" src="https://github.com/lastmile-ai/aiconfig/assets/5060851/ddb3284b-6d2b-4441-bed5-8b747dcc4268"> QUESTION: Once the server status is marked as error, do we want to keep the heartbeat going (is it possible for the server to recover without user manually restarting it?) ## Testing: - Load editor, ensure good status and no banner shown - CMD+C in CLI to shut down the editor. Make sure client shows the error banner - Start editor again. Client reloads and shows no error
- Loading branch information
Showing
7 changed files
with
104 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
python/src/aiconfig/editor/client/src/components/CopyButton.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import { | ||
CopyButton as MantineCopyButton, | ||
ActionIcon, | ||
Tooltip, | ||
} from "@mantine/core"; | ||
import { IconCheck, IconCopy } from "@tabler/icons-react"; | ||
|
||
type Props = { | ||
value: string; | ||
contentLabel?: string; | ||
}; | ||
export default function CopyButton({ value, contentLabel }: Props) { | ||
const labelSuffix = contentLabel ? ` ${contentLabel}` : ""; | ||
return ( | ||
<MantineCopyButton value={value} timeout={2000}> | ||
{({ copied, copy }) => ( | ||
<Tooltip | ||
label={copied ? `Copied${labelSuffix}` : `Copy${labelSuffix}`} | ||
withArrow | ||
> | ||
<ActionIcon color={copied ? "teal" : "gray"} onClick={copy}> | ||
{copied ? <IconCheck size="1rem" /> : <IconCopy size="1rem" />} | ||
</ActionIcon> | ||
</Tooltip> | ||
)} | ||
</MantineCopyButton> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
export const DEBOUNCE_MS = 300; | ||
export const AUTOSAVE_INTERVAL_MS = 15 * 1000; // 15 seconds | ||
export const SERVER_HEARTBEAT_INTERVAL_MS = 5 * 1000; // 5 seconds |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters