Matthias Nott
2026-03-08 4c266155785aad5050ebff7211e3d5f9e15c3238
contexts/ConnectionContext.tsx
....@@ -23,10 +23,10 @@
2323 status: ConnectionStatus;
2424 connect: (config?: ServerConfig) => void;
2525 disconnect: () => void;
26
- sendTextMessage: (text: string) => boolean;
27
- sendVoiceMessage: (audioBase64: string, transcript?: string, messageId?: string) => boolean;
28
- sendImageMessage: (imageBase64: string, caption: string, mimeType: string) => boolean;
29
- sendCommand: (command: string, args?: Record<string, unknown>) => boolean;
26
+ sendTextMessage: (text: string, sessionId?: string) => boolean;
27
+ sendVoiceMessage: (audioBase64: string, transcript?: string, messageId?: string, sessionId?: string) => boolean;
28
+ sendImageMessage: (imageBase64: string, caption: string, mimeType: string, sessionId?: string) => boolean;
29
+ sendCommand: (command: string, args?: Record<string, unknown>, sessionId?: string) => boolean;
3030 saveServerConfig: (config: ServerConfig) => Promise<void>;
3131 onMessageReceived: React.MutableRefObject<
3232 ((data: WsIncoming) => void) | null
....@@ -116,32 +116,33 @@
116116 setServerConfig(config);
117117 }, []);
118118
119
- const sendTextMessage = useCallback((text: string): boolean => {
120
- return wsClient.send({ type: "text", content: text });
119
+ const sendTextMessage = useCallback((text: string, sessionId?: string): boolean => {
120
+ return wsClient.send({ type: "text", content: text, sessionId });
121121 }, []);
122122
123123 const sendVoiceMessage = useCallback(
124
- (audioBase64: string, transcript: string = "", messageId?: string): boolean => {
124
+ (audioBase64: string, transcript: string = "", messageId?: string, sessionId?: string): boolean => {
125125 return wsClient.send({
126126 type: "voice",
127127 content: transcript,
128128 audioBase64,
129129 messageId,
130
+ sessionId,
130131 });
131132 },
132133 []
133134 );
134135
135136 const sendImageMessage = useCallback(
136
- (imageBase64: string, caption: string = "", mimeType: string = "image/jpeg"): boolean => {
137
- return wsClient.send({ type: "image", imageBase64, caption, mimeType });
137
+ (imageBase64: string, caption: string = "", mimeType: string = "image/jpeg", sessionId?: string): boolean => {
138
+ return wsClient.send({ type: "image", imageBase64, caption, mimeType, sessionId });
138139 },
139140 []
140141 );
141142
142143 const sendCommand = useCallback(
143
- (command: string, args?: Record<string, unknown>): boolean => {
144
- const msg: WsOutgoing = { type: "command", command, args };
144
+ (command: string, args?: Record<string, unknown>, sessionId?: string): boolean => {
145
+ const msg: WsOutgoing = { type: "command", command, args, sessionId };
145146 return wsClient.send(msg as any);
146147 },
147148 []