Skip to content

Commit 96e29aa

Browse files
committed
commit
1 parent 6c72394 commit 96e29aa

File tree

6 files changed

+77
-39
lines changed

6 files changed

+77
-39
lines changed

app/components/Input.tsx

+8-4
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,11 @@ export default function Input({ value, onValueChange, handelSubmit, graph, icon,
3636
useEffect(() => {
3737
const timeout = setTimeout(async () => {
3838

39-
if (!value || node?.id) return
39+
if (!value || node?.id) {
40+
setOptions([])
41+
setOpen(false)
42+
return
43+
}
4044

4145
const result = await fetch(`/api/repo/${graph.Id}/?prefix=${value}&type=autoComplete`, {
4246
method: 'POST'
@@ -71,10 +75,10 @@ export default function Input({ value, onValueChange, handelSubmit, graph, icon,
7175
if (!option) return
7276
if (handelSubmit) {
7377
handelSubmit(option)
78+
} else {
79+
if (!open) return
7480
onValueChange({ name: option.properties.name, id: option.id })
75-
}
76-
if (!open) return
77-
onValueChange({ name: option.properties.name, id: option.id })
81+
}
7882
setOpen(false)
7983
return
8084
}

app/components/chat.tsx

+7-29
Original file line numberDiff line numberDiff line change
@@ -344,18 +344,6 @@ export function Chat({ repo, path, setPath, graph, chartRef, selectedPathId, isP
344344

345345
const getTip = () =>
346346
<>
347-
<button
348-
className="Tip"
349-
onClick={() => {
350-
setTipOpen(false)
351-
}}
352-
>
353-
<Lightbulb />
354-
<div>
355-
<h1 className="label">Show unreachable code</h1>
356-
<p className="text">Remove it if unnecessary or fix logic issues.</p>
357-
</div>
358-
</button>
359347
<button
360348
className="Tip"
361349
onClick={() => {
@@ -364,16 +352,18 @@ export function Chat({ repo, path, setPath, graph, chartRef, selectedPathId, isP
364352
setMessages(prev => [
365353
...RemoveLastPath(prev),
366354
{ type: MessageTypes.Query, text: "Create a path" },
367-
{
368-
type: MessageTypes.Response,
369-
text: "Please select a starting point and the end point. Select or press relevant item on the graph"
370-
},
371-
{ type: MessageTypes.Path }
372355
])
356+
373357
if (isPathResponse) {
374358
chartRef.current?.elements().removeStyle().layout(LAYOUT).run()
375359
setIsPathResponse(false)
376360
}
361+
362+
setTimeout(() => setMessages(prev => [...prev, {
363+
type: MessageTypes.Response,
364+
text: "Please select a starting point and the end point. Select or press relevant item on the graph"
365+
}]), 300)
366+
setTimeout(() => setMessages(prev => [...prev, { type: MessageTypes.Path }]), 4000)
377367
}}
378368
>
379369
<Lightbulb />
@@ -382,18 +372,6 @@ export function Chat({ repo, path, setPath, graph, chartRef, selectedPathId, isP
382372
<p className="text">Fetch, update, batch, and navigate data efficiently</p>
383373
</div>
384374
</button>
385-
<button
386-
className="Tip"
387-
onClick={() => {
388-
setTipOpen(false)
389-
}}
390-
>
391-
<Lightbulb />
392-
<div>
393-
<h1 className="label">Show me cluster</h1>
394-
<p className="text">Scale and distribute workloads across multiple servers</p>
395-
</div>
396-
</button>
397375
</>
398376

399377
const getMessage = (message: Message, index?: number) => {

app/components/code-graph.tsx

+9-6
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import ElementMenu from "./elementMenu";
1111
import ElementTooltip from "./elementTooltip";
1212
import Combobox from "./combobox";
1313
import { toast } from '@/components/ui/use-toast';
14-
import { Path } from '../page';
14+
import { Path, PathNode } from '../page';
1515
import Input from './Input';
1616
import CommitList from './commitList';
1717
import { Checkbox } from '@/components/ui/checkbox';
@@ -136,7 +136,7 @@ export function CodeGraph({
136136
const [position, setPosition] = useState<Position>();
137137
const [tooltipPosition, setTooltipPosition] = useState<Position>();
138138
const [graphName, setGraphName] = useState<string>("");
139-
const [searchNodeName, setSearchNodeName] = useState<string>("");
139+
const [searchNode, setSearchNode] = useState<PathNode>({});
140140
const [commits, setCommits] = useState<any[]>([]);
141141
const [nodesCount, setNodesCount] = useState<number>(0);
142142
const [edgesCount, setEdgesCount] = useState<number>(0);
@@ -321,7 +321,9 @@ export function CodeGraph({
321321

322322
if (!chart) return
323323

324-
let chartNode = chart.elements(`node[name = "${node.properties.name}"]`)
324+
const n = { name: node.properties.name, id: node.id }
325+
326+
let chartNode = chart.elements(`node[name = "${n.name}"]`)
325327

326328
if (chartNode.length === 0) {
327329
const [newNode] = graph.extend({ nodes: [node], edges: [] })
@@ -331,7 +333,7 @@ export function CodeGraph({
331333
chartNode.select()
332334
const layout = { ...LAYOUT, padding: 250 }
333335
chartNode.layout(layout).run()
334-
setSearchNodeName("")
336+
setSearchNode(n)
335337
}
336338

337339
return (
@@ -353,10 +355,11 @@ export function CodeGraph({
353355
<div className='flex gap-4 pointer-events-auto'>
354356
<Input
355357
graph={graph}
356-
value={searchNodeName}
357-
onValueChange={(node) => setSearchNodeName(node.name!)}
358+
value={searchNode.name}
359+
onValueChange={({ name }) => setSearchNode({ name })}
358360
icon={<Search />}
359361
handelSubmit={handelSearchSubmit}
362+
node={searchNode}
360363
/>
361364
<Labels categories={graph.Categories} onClick={onCategoryClick} />
362365
</div>

components/ui/progress.tsx

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
"use client"
2+
3+
import * as React from "react"
4+
import * as ProgressPrimitive from "@radix-ui/react-progress"
5+
6+
import { cn } from "@/lib/utils"
7+
8+
const Progress = React.forwardRef<
9+
React.ElementRef<typeof ProgressPrimitive.Root>,
10+
React.ComponentPropsWithoutRef<typeof ProgressPrimitive.Root>
11+
>(({ className, value, ...props }, ref) => (
12+
<ProgressPrimitive.Root
13+
ref={ref}
14+
className={cn(
15+
"relative h-4 w-full overflow-hidden rounded-full bg-secondary",
16+
className
17+
)}
18+
{...props}
19+
>
20+
<ProgressPrimitive.Indicator
21+
className="h-full w-full flex-1 bg-primary transition-all"
22+
style={{ transform: `translateX(-${100 - (value || 0)}%)` }}
23+
/>
24+
</ProgressPrimitive.Root>
25+
))
26+
Progress.displayName = ProgressPrimitive.Root.displayName
27+
28+
export { Progress }

package-lock.json

+24
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
"@radix-ui/react-dialog": "^1.1.2",
1414
"@radix-ui/react-dropdown-menu": "^2.1.2",
1515
"@radix-ui/react-hover-card": "^1.1.2",
16+
"@radix-ui/react-progress": "^1.1.0",
1617
"@radix-ui/react-select": "^2.0.0",
1718
"@radix-ui/react-slot": "^1.0.2",
1819
"@radix-ui/react-toast": "^1.1.5",

0 commit comments

Comments
 (0)