Skip to content
This repository has been archived by the owner on Sep 16, 2024. It is now read-only.

fix: terminal max retry count #734

Merged
merged 1 commit into from
Mar 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 21 additions & 5 deletions src/components/x-terminal/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@
const toRetry = ref(false);
const RECONNECT_MSG = '--- press Y to reconnect! ---';
const appStore = useAppStore();
const totalRetry = 5;
const retryCount = ref(5);
let timer: any = null;

const conReadyState = ref(0);

Expand Down Expand Up @@ -278,6 +281,15 @@
actived.value = false;
if (terminalSocket.value) terminalSocket.value?.close?.();
};
const retryWs = () => {
if (retryCount.value > 0) {
retryCount.value -= 1;
term.value?.write?.('');
setWssUrl();
initWS();
term.value.reset();
}
};
watch(
() => props.url,
() => {
Expand All @@ -286,6 +298,10 @@
terminalSocket.value?.close?.();
terminalSocket.value = {};
} else {
// reset retry count
retryCount.value = totalRetry;
clearTimeout(timer);

term.value?.reset?.();
debounceCall();
}
Expand All @@ -297,11 +313,11 @@
watch(
() => statusCode.value,
(ov) => {
if (statusCode.value === 1003) {
term.value?.write?.('');
setWssUrl();
initWS();
term.value.reset();
if (statusCode.value === 1003 && retryCount.value > 0) {
clearTimeout(timer);
timer = setTimeout(() => {
retryWs();
}, 2 ** (totalRetry - retryCount.value) * 1000);
}
},
{
Expand Down
36 changes: 19 additions & 17 deletions src/views/operation-hub/templates/pages/gpt.vue
Original file line number Diff line number Diff line change
Expand Up @@ -110,30 +110,32 @@
}}
</div>
</template>
<a-button
ref="correctionButton"
:disabled="loading"
type="outline"
shape="circle"
class="correction-btn"
@click="handleViewCorrection"
<a-tooltip
:content="$t('operation.templates.detail.correctionview')"
position="tr"
:arrow-style="{
left: '95px'
}"
>
<a-tooltip
:content="$t('operation.templates.detail.correctionview')"
<a-button
ref="correctionButton"
:disabled="loading"
type="outline"
shape="circle"
class="correction-btn"
@click="handleViewCorrection"
>
<template #content>
<div style="width: max-content">{{
$t('operation.templates.detail.correctionview')
}}</div>
</template>
<span>
<icon-font
type="icon-shoudongxiaoyan"
class="size-16"
></icon-font>
</span>
</a-tooltip>
</a-button>
<icon-font
type="icon-shoudongxiaoyan"
class="size-16"
></icon-font>
</a-button>
</a-tooltip>
</a-tooltip>
</a-space>
</div>
Expand Down
Loading