Skip to content

Commit 39becc8

Browse files
authored
fix: auto save tool & bump app version (#1100)
* remove ref dependencies * ensure not triggering when saving tool * only make optimistic updates in messages once * bump app version
1 parent 3839745 commit 39becc8

File tree

4 files changed

+10
-40
lines changed

4 files changed

+10
-40
lines changed

apps/shinkai-desktop/src/components/chat/websocket-message.tsx

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -191,25 +191,6 @@ export const useWebSocketMessage = ({
191191
}
192192
}),
193193
);
194-
195-
if (parseData.metadata?.is_done === true) {
196-
queryClient.setQueryData(
197-
queryKey,
198-
produce((draft: ChatConversationInfiniteData | undefined) => {
199-
if (!draft?.pages?.[0]) return;
200-
const lastMessage = draft.pages.at(-1)?.at(-1);
201-
if (
202-
lastMessage &&
203-
lastMessage.role === 'assistant' &&
204-
lastMessage.messageId === OPTIMISTIC_ASSISTANT_MESSAGE_ID
205-
) {
206-
lastMessage.status = { type: 'complete', reason: 'unknown' };
207-
}
208-
}),
209-
);
210-
211-
return;
212-
}
213194
} catch (error) {
214195
console.error('Failed to parse ws message', error);
215196
}
@@ -262,7 +243,6 @@ export const useWebSocketTools = ({
262243
const { inboxId: encodedInboxId = '' } = useParams();
263244
const inboxId = defaultInboxId || decodeURIComponent(encodedInboxId);
264245
const queryClient = useQueryClient();
265-
const isToolReceived = useRef(false);
266246

267247
const setWidget = useToolsStore((state) => state.setWidget);
268248

@@ -277,23 +257,10 @@ export const useWebSocketTools = ({
277257
const parseData: WsMessage = JSON.parse(lastMessage.data);
278258
if (parseData.inbox !== inboxId) return;
279259

280-
if (
281-
parseData.message_type === 'ShinkaiMessage' &&
282-
isToolReceived.current
283-
) {
284-
isToolReceived.current = false;
285-
const paginationKey = [
286-
FunctionKeyV2.GET_CHAT_CONVERSATION_PAGINATION,
287-
{ inboxId: inboxId as string },
288-
];
289-
void queryClient.invalidateQueries({ queryKey: paginationKey });
290-
return;
291-
}
292260
if (
293261
parseData.message_type === 'Widget' &&
294262
parseData?.widget?.ToolRequest
295263
) {
296-
isToolReceived.current = true;
297264
const tool = parseData.widget.ToolRequest;
298265
queryClient.setQueryData(
299266
queryKey,

apps/shinkai-desktop/src/components/playground-tool/hooks/use-tool-flow.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -451,13 +451,17 @@ export const useToolFlow = ({
451451
}
452452
}
453453
}
454+
// eslint-disable-next-line react-hooks/exhaustive-deps
454455
}, [
455456
metadataConversation?.pages,
456457
setToolMetadata,
457458
setToolMetadataStatus,
458459
setToolMetadataError,
459460
isPlaygroundMode,
460461
toolMetadataStatus,
462+
sendMetadataGenerationCompleteNotification,
463+
setCurrentStep,
464+
setToolCreationError,
461465
]);
462466

463467
useEffect(() => {
@@ -592,7 +596,8 @@ export const useToolFlow = ({
592596
toolMetadata &&
593597
toolCodeStatus === 'success' &&
594598
toolMetadataStatus === 'success' &&
595-
forceAutoSave.current
599+
forceAutoSave.current &&
600+
!isSavingTool
596601
) {
597602
forceAutoSave.current = false;
598603
forceGenerateMetadata.current = false;
@@ -623,9 +628,7 @@ export const useToolFlow = ({
623628
handleSaveTool,
624629
form,
625630
setCurrentStep,
626-
forceAutoSave,
627-
forceGenerateMetadata,
628-
forceGenerateCode,
631+
isSavingTool,
629632
]);
630633

631634
const handleApplyChangesCodeSubmit = useCallback(

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@shinkai/source",
3-
"version": "1.1.14",
3+
"version": "1.1.15",
44
"license": "SEE LICENSE IN LICENSE",
55
"files": [
66
"LICENSE"

0 commit comments

Comments
 (0)