Skip to content

Commit a72a22c

Browse files
authored
relayouts the graph using Dagre when a replace change causes node intersections (#461)
1 parent 521a908 commit a72a22c

File tree

3 files changed

+28
-0
lines changed

3 files changed

+28
-0
lines changed

.changeset/tricky-cycles-hide.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@inkeep/agents-manage-ui": patch
3+
---
4+
5+
Add `⌘ + S` / `Ctrl + S` (windows) shortcut to save changes

agents-manage-ui/src/components/graph/toolbar/toolbar.tsx

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ import { Play, Settings } from 'lucide-react';
22
import { Button } from '@/components/ui/button';
33
import { Tooltip, TooltipContent, TooltipTrigger } from '@/components/ui/tooltip';
44
import { useGraphStore } from '@/features/graph/state/use-graph-store';
5+
import { useEffect, useRef } from 'react';
6+
import { isMacOs } from '@/lib/utils';
57

68
interface ToolbarProps {
79
onSubmit: () => void;
@@ -17,6 +19,7 @@ export function Toolbar({
1719
setShowPlayground,
1820
}: ToolbarProps) {
1921
const dirty = useGraphStore((state) => state.dirty);
22+
const saveButtonRef = useRef<HTMLButtonElement>(null!);
2023
const PreviewButton = (
2124
<Button
2225
disabled={dirty || isPreviewDisabled}
@@ -29,6 +32,21 @@ export function Toolbar({
2932
</Button>
3033
);
3134

35+
useEffect(() => {
36+
function handleSaveShortcut(event: KeyboardEvent) {
37+
const isShortcutPressed = (isMacOs() ? event.metaKey : event.ctrlKey) && event.key === 's';
38+
if (!isShortcutPressed) return;
39+
event.preventDefault();
40+
// Using button ref instead onSubmit to respect button's disabled state
41+
saveButtonRef.current.click();
42+
}
43+
44+
window.addEventListener('keydown', handleSaveShortcut);
45+
return () => {
46+
window.removeEventListener('keydown', handleSaveShortcut);
47+
};
48+
}, []);
49+
3250
return (
3351
<div className="flex gap-2">
3452
{dirty || isPreviewDisabled ? (
@@ -49,6 +67,7 @@ export function Toolbar({
4967
onClick={onSubmit}
5068
variant={dirty ? 'default' : 'outline'}
5169
disabled={!dirty && !isPreviewDisabled}
70+
ref={saveButtonRef}
5271
>
5372
{isPreviewDisabled ? 'Save' : 'Save changes'}
5473
</Button>

agents-manage-ui/src/lib/utils.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
import { type ClassValue, clsx } from 'clsx';
22
import { twMerge } from 'tailwind-merge';
33

4+
export function isMacOs() {
5+
return typeof navigator !== 'undefined' && navigator.userAgent.includes('Mac');
6+
}
7+
48
export function cn(...inputs: ClassValue[]) {
59
return twMerge(clsx(inputs));
610
}

0 commit comments

Comments
 (0)