Skip to content

Commit 63df81d

Browse files
authored
Merge branch 'staging' into CanvasAnalysisAndTests
2 parents bb6984f + 5802392 commit 63df81d

File tree

5 files changed

+45
-42
lines changed

5 files changed

+45
-42
lines changed

.github/dependabot.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,6 @@ updates:
88
- package-ecosystem: "npm" # See documentation for possible values
99
directory: "/" # Location of package manifests
1010
schedule:
11-
interval: "weekly"
11+
interval: "daily"
12+
target-branch: "staging"
1213

app/api/repo/[graph]/route.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ export async function GET(request: NextRequest, { params }: { params: { graph: s
3232
export async function POST(request: NextRequest, { params }: { params: { graph: string } }) {
3333

3434
const repo = params.graph
35-
const prefix = request.nextUrl.searchParams.get('prefix')!
35+
const prefix = request.nextUrl.searchParams.get('prefix')
3636

3737
try {
3838

app/components/chat.tsx

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -92,46 +92,53 @@ const SUGGESTIONS = [
9292

9393
const RemoveLastPath = (messages: Message[]) => {
9494
const index = messages.findIndex((m) => m.type === MessageTypes.Path)
95-
95+
9696
if (index !== -1) {
9797
messages = [...messages.slice(0, index - 2), ...messages.slice(index + 1)];
9898
messages = RemoveLastPath(messages)
9999
}
100-
100+
101101
return messages
102102
}
103103

104104
export function Chat({ repo, path, setPath, graph, chartRef, selectedPathId, isPath, setIsPath }: Props) {
105-
105+
106106
// Holds the messages in the chat
107107
const [messages, setMessages] = useState<Message[]>([]);
108-
108+
109109
// Holds the messages in the chat
110110
const [paths, setPaths] = useState<{ nodes: any[], edges: any[] }[]>([]);
111-
111+
112112
const [selectedPath, setSelectedPath] = useState<{ nodes: any[], edges: any[] }>();
113-
113+
114114
// Holds the user input while typing
115115
const [query, setQuery] = useState('');
116-
116+
117117
const [isPathResponse, setIsPathResponse] = useState(false);
118-
118+
119119
const [tipOpen, setTipOpen] = useState(false);
120-
120+
121121
const [sugOpen, setSugOpen] = useState(false);
122-
122+
123123
// A reference to the chat container to allow scrolling to the bottom
124124
const containerRef: React.RefObject<HTMLDivElement> = useRef(null);
125-
125+
126126
const isSendMessage = messages.some(m => m.type === MessageTypes.Pending) || (messages.some(m => m.text === "Please select a starting point and the end point. Select or press relevant item on the graph") && !messages.some(m => m.type === MessageTypes.Path))
127-
127+
128128
useEffect(() => {
129129
const p = paths.find((path) => [...path.edges, ...path.nodes].some((e: any) => e.id === selectedPathId))
130-
130+
131131
if (!p) return
132-
132+
133133
handleSetSelectedPath(p)
134134
}, [selectedPathId])
135+
136+
// Scroll to the bottom of the chat on new message
137+
useEffect(() => {
138+
setTimeout(() => {
139+
containerRef.current?.scrollTo(0, containerRef.current?.scrollHeight);
140+
}, 300)
141+
}, [messages]);
135142

136143
useEffect(() => {
137144
handleSubmit()
@@ -261,13 +268,6 @@ export function Chat({ repo, path, setPath, graph, chartRef, selectedPathId, isP
261268

262269
}
263270

264-
// Scroll to the bottom of the chat on new message
265-
useEffect(() => {
266-
setTimeout(() => {
267-
containerRef.current?.scrollTo(0, containerRef.current?.scrollHeight);
268-
}, 300)
269-
}, [messages]);
270-
271271
const handleSubmit = async () => {
272272
setSelectedPath(undefined)
273273

@@ -329,7 +329,7 @@ export function Chat({ repo, path, setPath, graph, chartRef, selectedPathId, isP
329329
});
330330
elements.layout(LAYOUT).run()
331331
setPaths(formattedPaths)
332-
setMessages(prev => [...(prev.some(m => m.type === MessageTypes.Path) ? prev.slice(0, -2) : prev), { type: MessageTypes.PathResponse, paths: formattedPaths }])
332+
setMessages((prev) => [...RemoveLastPath(prev), { type: MessageTypes.PathResponse, paths: formattedPaths }]);
333333
setPath(undefined)
334334
setIsPathResponse(true)
335335
}

package-lock.json

Lines changed: 19 additions & 17 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
"autoprefixer": "^10.4.20",
2222
"class-variance-authority": "^0.7.0",
2323
"clsx": "^2.1.0",
24-
"cytoscape": "^3.28.1",
24+
"cytoscape": "^3.30.4",
2525
"cytoscape-fcose": "^2.2.0",
2626
"lucide-react": "^0.441.0",
2727
"next": "14.2.18",

0 commit comments

Comments
 (0)