Skip to content

Commit c05702a

Browse files
committed
Refactor HomeInput and HomePage hooks and formatting
Explicitly typed useState hooks in HomeInput for better type safety and improved code formatting. Removed unnecessary dependencies from useEffect in HomePage to prevent unwanted re-renders.
1 parent e2b16f3 commit c05702a

File tree

2 files changed

+23
-23
lines changed

2 files changed

+23
-23
lines changed

src/frontend/src/components/content/HomeInput.tsx

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -35,17 +35,17 @@ const getIconFromString = (iconString: string | React.ReactNode): React.ReactNod
3535

3636
const truncateDescription = (description: string, maxLength: number = 180): string => {
3737
if (!description) return '';
38-
38+
3939
if (description.length <= maxLength) {
4040
return description;
4141
}
42-
42+
4343

4444
const truncated = description.substring(0, maxLength);
4545
const lastSpaceIndex = truncated.lastIndexOf(' ');
46-
46+
4747
const cutPoint = lastSpaceIndex > maxLength - 20 ? lastSpaceIndex : maxLength;
48-
48+
4949
return description.substring(0, cutPoint) + '...';
5050
};
5151

@@ -57,8 +57,8 @@ interface ExtendedQuickTask extends QuickTask {
5757
const HomeInput: React.FC<HomeInputProps> = ({
5858
selectedTeam,
5959
}) => {
60-
const [submitting, setSubmitting] = useState(false);
61-
const [input, setInput] = useState("");
60+
const [submitting, setSubmitting] = useState<boolean>(false);
61+
const [input, setInput] = useState<string>("");
6262
const [raiError, setRAIError] = useState<RAIErrorData | null>(null);
6363

6464
const textareaRef = useRef<HTMLTextAreaElement>(null);
@@ -129,10 +129,10 @@ const HomeInput: React.FC<HomeInputProps> = ({
129129
errorDetail = error?.response?.data?.detail;
130130
}
131131

132-
// Handle RAI validation errors - just show description as toast
132+
// Handle RAI validation errors - just show description as toast
133133
if (errorDetail?.error_type === 'RAI_VALIDATION_FAILED') {
134-
const description = errorDetail.description ||
135-
"Your request contains content that doesn't meet our safety guidelines. Please try rephrasing.";
134+
const description = errorDetail.description ||
135+
"Your request contains content that doesn't meet our safety guidelines. Please try rephrasing.";
136136
showToast(description, "error");
137137
} else {
138138
// Handle other errors with toast messages
@@ -141,7 +141,7 @@ const HomeInput: React.FC<HomeInputProps> = ({
141141
error?.response?.data?.message ||
142142
error?.message ||
143143
"Something went wrong. Please try again.";
144-
144+
145145
showToast(errorMessage, "error");
146146
}
147147
} finally {
@@ -242,18 +242,18 @@ const HomeInput: React.FC<HomeInputProps> = ({
242242

243243
<div className="home-input-quick-tasks">
244244
<div>
245-
{tasksToDisplay.map((task) => (
246-
<PromptCard
247-
key={task.id}
248-
title={task.title}
249-
icon={task.icon}
250-
description={task.description}
251-
onClick={() => handleQuickTaskClick(task)}
252-
disabled={submitting}
253-
254-
/>
255-
))}
256-
</div>
245+
{tasksToDisplay.map((task) => (
246+
<PromptCard
247+
key={task.id}
248+
title={task.title}
249+
icon={task.icon}
250+
description={task.description}
251+
onClick={() => handleQuickTaskClick(task)}
252+
disabled={submitting}
253+
254+
/>
255+
))}
256+
</div>
257257
</div>
258258
</>
259259
)}

src/frontend/src/pages/HomePage.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ const HomePage: React.FC = () => {
8383
};
8484

8585
initTeam();
86-
}, [setIsLoadingTeam, showToast, navigate, setReloadLeftList]);
86+
}, []);
8787

8888
/**
8989
* Handle new task creation from the "New task" button

0 commit comments

Comments
 (0)