Skip to content

Commit

Permalink
Fixed a bug that cause crash on Linux whenever we use clear history o…
Browse files Browse the repository at this point in the history
…n Chat WebUI
  • Loading branch information
Kagamma committed Dec 29, 2023
1 parent 1bb20b6 commit d9f3f5e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
6 changes: 5 additions & 1 deletion src/com/com.webapp.pas
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,12 @@ procedure WebUI_API_ChatHistoryClear(Req: TRequest; Res: TResponse);
end;

procedure WebUI_API_ChatHistorySavePlainText(Req: TRequest; Res: TResponse);
var
Thread: TWebUIToNativeUIThread;
begin
FormChat.SaveHistory(Req.Content);
Thread := TWebUIToNativeUIThread.Create(@WebUI_ChatServiceSavePlainTextProc, Req.Content);
Thread.Start;
WaitForThreadTerminate(Thread.ThreadID, 5000);
end;

procedure WebUI_API_ChatIsStreaming(Req: TRequest; Res: TResponse);
Expand Down
11 changes: 10 additions & 1 deletion src/forms/form.chat_webui.inc
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ type
procedure WebUI_ChatSendProc(S: String);
procedure WebUI_ChatServiceEditProc(S: String);
procedure WebUI_ChatServiceSetProc(S: String);
procedure WebUI_ChatServiceSavePlainTextProc(S: String);
function WebUI_ChatServiceGetTypeProc: String;
{$endif unit_declare_interface}

Expand Down Expand Up @@ -142,9 +143,17 @@ begin
FormChat.ClearHistory;
end;

procedure WebUI_ChatServiceSavePlainTextProc(S: String);
begin
FormChat.SaveHistory(S);
end;
procedure WebUI_ChatHistorySavePlainText(E: PWebUIEvent);
var
Thread: TWebUIToNativeUIThread;
begin
FormChat.SaveHistory(webui_get_string(E));
Thread := TWebUIToNativeUIThread.Create(@WebUI_ChatServiceSavePlainTextProc, webui_get_string(E));
Thread.Start;
WaitForThreadTerminate(Thread.ThreadID, 5000);
end;

procedure WebUI_ChatServiceSetProc(S: String);
Expand Down

0 comments on commit d9f3f5e

Please sign in to comment.