@@ -23,6 +23,7 @@ const loading = ref(true);
2323const store = useStore ();
2424const botService = new BotService ();
2525const mcpService = new MCPService ();
26+ const callbackProxy = ref ();
2627const props = defineProps ([' room' ]);
2728const emits = defineEmits ([' back' ,' peer' ,' manager' ,' history' ,' notify' ,' update:room' ]);
2829const selectedMesh = computed (() => {
@@ -82,7 +83,7 @@ const makeToolcall = () => {
8283const cancelToolcall = () => {
8384 openToolcallEditor .value = false ;
8485 toolcallTarget .value .status = " cancel"
85- callbackProxy (
86+ callbackProxy . value (
8687 msgHtml (lastmsg .value , toolcallTarget .value ),
8788 false ,
8889 true
@@ -109,7 +110,7 @@ const openToolcall = () => {
109110 openToolcallEditor .value = true ;
110111 loaddata ();
111112 setTimeout (()=> {
112- callbackProxy (
113+ callbackProxy . value (
113114 msgHtml (lastmsg .value , toolcallTarget .value ),
114115 false ,
115116 false
@@ -251,17 +252,16 @@ const inputStyle = computed(() => {
251252})
252253const hasMediaDevices = computed (() => true );
253254const delta = ref (' ' );
254- let callbackProxy = null ;
255255const workerOnMessage = (msg ) => {
256256 const toolcall = store .getters [" mcp/toolcall" ]
257257 if (msg? .message ){
258- callbackProxy (
258+ callbackProxy . value (
259259 msgHtml (msg? .message , toolcall),
260260 true
261261 );
262262 } else {
263263 setTimeout (()=> {
264- callbackProxy (
264+ callbackProxy . value (
265265 msgHtml (msg? .delta , toolcall),
266266 msg? .ending ,
267267 ! msg? .first
@@ -396,7 +396,7 @@ const request = ref({
396396 // writeMobileFile('postMessageHTML.txt',html);
397397 chat.value.addMessage({role: 'user',html:html},false);
398398 }
399- callbackProxy = (html2,ending)=>{
399+ callbackProxy.value = (html2,ending)=>{
400400 //body
401401 // let html2 = "";
402402 // body?.files.forEach((file)=>{
@@ -430,7 +430,7 @@ const request = ref({
430430 }else if(body?.messages){
431431
432432 if(body?.messages[0]){
433- callbackProxy = (html,ending,overwrite) => {
433+ callbackProxy.value = (html,ending,overwrite) => {
434434 // loading.value = false;
435435 signals.onResponse({files:[],overwrite: true});
436436 chat.value.addMessage({html,role: 'ai',overwrite: overwrite},overwrite);
@@ -485,6 +485,12 @@ const openPeer = () => {
485485 emits('peer',llm.value?.name);
486486}
487487
488+ const streaming = computed(() => !!callbackProxy.value )
489+ const chatCancel = () => {
490+ botService.chatCancel();
491+ callbackProxy.value = null;
492+ loading.value = false;
493+ }
488494const loadllm = (callback) => {
489495 botService.checkLLM(props?.room?.id,(res) => {
490496 llm.value = res;
@@ -569,6 +575,7 @@ defineExpose({
569575 <template #end>
570576 <Button icon="pi pi-history" @click="gohistory" severity="secondary" text />
571577 <Button icon="pi pi-cog" @click="showManage" severity="secondary" text />
578+ <Button v-if="streaming" icon="pi pi-stop-circle" @click="chatCancel()" severity="danger" text />
572579 </template>
573580 </AppHeader>
574581 <div class="w-full flex" style="height: calc(100vh - 37px);flex: 1;margin: 0;flex-direction: column;">
0 commit comments