Skip to content

Commit 80854d9

Browse files
authored
Merge branch 'main' into set-header
2 parents a010f10 + 70dc1b7 commit 80854d9

File tree

7 files changed

+45
-37
lines changed

7 files changed

+45
-37
lines changed

client/src/components/Sidebar.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -447,7 +447,13 @@ const Sidebar = ({
447447
<div className="space-y-2">
448448
{connectionStatus === "connected" && (
449449
<div className="grid grid-cols-2 gap-4">
450-
<Button data-testid="connect-button" onClick={onConnect}>
450+
<Button
451+
data-testid="connect-button"
452+
onClick={() => {
453+
onDisconnect();
454+
onConnect();
455+
}}
456+
>
451457
<RotateCcw className="w-4 h-4 mr-2" />
452458
{transportType === "stdio" ? "Restart" : "Reconnect"}
453459
</Button>

client/src/components/ui/button.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,4 +54,4 @@ const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(
5454
);
5555
Button.displayName = "Button";
5656

57-
export { Button, buttonVariants };
57+
export { Button };

client/src/components/ui/input.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@ import * as React from "react";
22

33
import { cn } from "@/lib/utils";
44

5-
export interface InputProps
6-
extends React.InputHTMLAttributes<HTMLInputElement> {}
5+
export type InputProps = React.InputHTMLAttributes<HTMLInputElement>;
76

87
const Input = React.forwardRef<HTMLInputElement, InputProps>(
98
({ className, type, ...props }, ref) => {

client/src/components/ui/textarea.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@ import * as React from "react";
22

33
import { cn } from "@/lib/utils";
44

5-
export interface TextareaProps
6-
extends React.TextareaHTMLAttributes<HTMLTextAreaElement> {}
5+
export type TextareaProps = React.TextareaHTMLAttributes<HTMLTextAreaElement>;
76

87
const Textarea = React.forwardRef<HTMLTextAreaElement, TextareaProps>(
98
({ className, ...props }, ref) => {

client/src/hooks/use-toast.ts

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -15,37 +15,35 @@ type ToasterToast = ToastProps & {
1515
action?: ToastActionElement;
1616
};
1717

18-
const actionTypes = {
19-
ADD_TOAST: "ADD_TOAST",
20-
UPDATE_TOAST: "UPDATE_TOAST",
21-
DISMISS_TOAST: "DISMISS_TOAST",
22-
REMOVE_TOAST: "REMOVE_TOAST",
23-
} as const;
24-
2518
let count = 0;
2619

2720
function genId() {
2821
count = (count + 1) % Number.MAX_SAFE_INTEGER;
2922
return count.toString();
3023
}
3124

32-
type ActionType = typeof actionTypes;
25+
const enum ActionType {
26+
ADD_TOAST = "ADD_TOAST",
27+
UPDATE_TOAST = "UPDATE_TOAST",
28+
DISMISS_TOAST = "DISMISS_TOAST",
29+
REMOVE_TOAST = "REMOVE_TOAST",
30+
}
3331

3432
type Action =
3533
| {
36-
type: ActionType["ADD_TOAST"];
34+
type: ActionType.ADD_TOAST;
3735
toast: ToasterToast;
3836
}
3937
| {
40-
type: ActionType["UPDATE_TOAST"];
38+
type: ActionType.UPDATE_TOAST;
4139
toast: Partial<ToasterToast>;
4240
}
4341
| {
44-
type: ActionType["DISMISS_TOAST"];
42+
type: ActionType.DISMISS_TOAST;
4543
toastId?: ToasterToast["id"];
4644
}
4745
| {
48-
type: ActionType["REMOVE_TOAST"];
46+
type: ActionType.REMOVE_TOAST;
4947
toastId?: ToasterToast["id"];
5048
};
5149

@@ -63,7 +61,7 @@ const addToRemoveQueue = (toastId: string) => {
6361
const timeout = setTimeout(() => {
6462
toastTimeouts.delete(toastId);
6563
dispatch({
66-
type: "REMOVE_TOAST",
64+
type: ActionType.REMOVE_TOAST,
6765
toastId: toastId,
6866
});
6967
}, TOAST_REMOVE_DELAY);
@@ -73,21 +71,21 @@ const addToRemoveQueue = (toastId: string) => {
7371

7472
export const reducer = (state: State, action: Action): State => {
7573
switch (action.type) {
76-
case "ADD_TOAST":
74+
case ActionType.ADD_TOAST:
7775
return {
7876
...state,
7977
toasts: [action.toast, ...state.toasts].slice(0, TOAST_LIMIT),
8078
};
8179

82-
case "UPDATE_TOAST":
80+
case ActionType.UPDATE_TOAST:
8381
return {
8482
...state,
8583
toasts: state.toasts.map((t) =>
8684
t.id === action.toast.id ? { ...t, ...action.toast } : t,
8785
),
8886
};
8987

90-
case "DISMISS_TOAST": {
88+
case ActionType.DISMISS_TOAST: {
9189
const { toastId } = action;
9290

9391
// ! Side effects ! - This could be extracted into a dismissToast() action,
@@ -112,7 +110,7 @@ export const reducer = (state: State, action: Action): State => {
112110
),
113111
};
114112
}
115-
case "REMOVE_TOAST":
113+
case ActionType.REMOVE_TOAST:
116114
if (action.toastId === undefined) {
117115
return {
118116
...state,
@@ -144,13 +142,14 @@ function toast({ ...props }: Toast) {
144142

145143
const update = (props: ToasterToast) =>
146144
dispatch({
147-
type: "UPDATE_TOAST",
145+
type: ActionType.UPDATE_TOAST,
148146
toast: { ...props, id },
149147
});
150-
const dismiss = () => dispatch({ type: "DISMISS_TOAST", toastId: id });
148+
const dismiss = () =>
149+
dispatch({ type: ActionType.DISMISS_TOAST, toastId: id });
151150

152151
dispatch({
153-
type: "ADD_TOAST",
152+
type: ActionType.ADD_TOAST,
154153
toast: {
155154
...props,
156155
id,
@@ -184,7 +183,8 @@ function useToast() {
184183
return {
185184
...state,
186185
toast,
187-
dismiss: (toastId?: string) => dispatch({ type: "DISMISS_TOAST", toastId }),
186+
dismiss: (toastId?: string) =>
187+
dispatch({ type: ActionType.DISMISS_TOAST, toastId }),
188188
};
189189
}
190190

client/src/lib/hooks/useCompletionState.ts

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { useState, useCallback, useEffect, useRef } from "react";
1+
import { useState, useCallback, useEffect, useRef, useMemo } from "react";
22
import {
33
ResourceReference,
44
PromptReference,
@@ -15,9 +15,11 @@ function debounce<T extends (...args: any[]) => PromiseLike<void>>(
1515
wait: number,
1616
): (...args: Parameters<T>) => void {
1717
let timeout: ReturnType<typeof setTimeout>;
18-
return function (...args: Parameters<T>) {
18+
return (...args: Parameters<T>) => {
1919
clearTimeout(timeout);
20-
timeout = setTimeout(() => func(...args), wait);
20+
timeout = setTimeout(() => {
21+
void func(...args);
22+
}, wait);
2123
};
2224
}
2325

@@ -58,8 +60,8 @@ export function useCompletionState(
5860
});
5961
}, [cleanup]);
6062

61-
const requestCompletions = useCallback(
62-
debounce(
63+
const requestCompletions = useMemo(() => {
64+
return debounce(
6365
async (
6466
ref: ResourceReference | PromptReference,
6567
argName: string,
@@ -94,7 +96,7 @@ export function useCompletionState(
9496
loading: { ...prev.loading, [argName]: false },
9597
}));
9698
}
97-
} catch (err) {
99+
} catch {
98100
if (!abortController.signal.aborted) {
99101
setState((prev) => ({
100102
...prev,
@@ -108,9 +110,8 @@ export function useCompletionState(
108110
}
109111
},
110112
debounceMs,
111-
),
112-
[handleCompletion, completionsSupported, cleanup, debounceMs],
113-
);
113+
);
114+
}, [handleCompletion, completionsSupported, cleanup, debounceMs]);
114115

115116
// Clear completions when support status changes
116117
useEffect(() => {

client/src/lib/useTheme.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,10 @@ const useTheme = (): [Theme, (mode: Theme) => void] => {
4343
document.documentElement.classList.toggle("dark", newTheme === "dark");
4444
}
4545
}, []);
46-
return useMemo(() => [theme, setThemeWithSideEffect], [theme]);
46+
return useMemo(
47+
() => [theme, setThemeWithSideEffect],
48+
[theme, setThemeWithSideEffect],
49+
);
4750
};
4851

4952
export default useTheme;

0 commit comments

Comments
 (0)