Skip to content

Commit 81c9b93

Browse files
committed
Memoize Flow Chart component
1 parent dfc1b9a commit 81c9b93

File tree

5 files changed

+234
-198
lines changed

5 files changed

+234
-198
lines changed

src/components/Agentic/IncidentDetails/IncidentMetaData/IdeToolbar/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ const IDE_ICONS: Record<string, ComponentType<IconProps>> = {
2020
export const IdeToolbar = ({ incidentId }: IdeToolbarProps) => {
2121
const [ides, setIdes] = useState<VSCodeExtensionInfo[]>();
2222

23-
const handleIdeButtonClick = (ide: string) => {
23+
const handleIdeButtonClick = (ide: string) => () => {
2424
sendUserActionTrackingEvent(trackingEvents.INCIDENT_IDE_BUTTON_CLICKED, {
2525
ide
2626
});
@@ -68,7 +68,7 @@ export const IdeToolbar = ({ incidentId }: IdeToolbarProps) => {
6868
size={"large"}
6969
key={ide.ideUriScheme}
7070
icon={(props) => <IdeIcon {...props} />}
71-
onClick={() => handleIdeButtonClick(ide.ideUriScheme)}
71+
onClick={handleIdeButtonClick(ide.ideUriScheme)}
7272
/>
7373
</Tooltip>
7474
);

src/components/Agentic/IncidentDetails/index.tsx

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { Allotment } from "allotment";
22
import "allotment/dist/style.css";
3-
import { useEffect, useState } from "react";
3+
import { useCallback, useEffect, useState } from "react";
44
import { useParams } from "react-router";
55
import { useTheme } from "styled-components";
66
import { useAgenticDispatch } from "../../../containers/Agentic/hooks";
@@ -113,6 +113,20 @@ export const IncidentDetails = () => {
113113
);
114114
};
115115

116+
const handleAgentSelect = useCallback(
117+
(id: string | null) => {
118+
setSearchParams((params) => {
119+
if (id) {
120+
params.set("agent", id);
121+
} else {
122+
params.delete("agent");
123+
}
124+
return params;
125+
});
126+
},
127+
[setSearchParams]
128+
);
129+
116130
useEffect(() => {
117131
setAgentViewMode("summary");
118132
}, [agentId]);
@@ -137,17 +151,6 @@ export const IncidentDetails = () => {
137151
(agent) => agent.name === `${agentId}_chat`
138152
);
139153

140-
const handleAgentSelect = (id: string | null) => {
141-
setSearchParams((params) => {
142-
if (id) {
143-
params.set("agent", id);
144-
} else {
145-
params.delete("agent");
146-
}
147-
return params;
148-
});
149-
};
150-
151154
if (!incidentData && isLoading) {
152155
return (
153156
<s.Container>

0 commit comments

Comments
 (0)