fix(step2): add null-guard for task_id in pollTaskUntilDone, add try/catch to confirmDeleteAgent
This commit is contained in:
parent
c7bc4d5ad0
commit
34962edc20
|
|
@ -613,7 +613,7 @@
|
||||||
<p><strong>Persona:</strong> {{ selectedAgent?.persona }}</p>
|
<p><strong>Persona:</strong> {{ selectedAgent?.persona }}</p>
|
||||||
<div class="modal-actions">
|
<div class="modal-actions">
|
||||||
<button class="btn-secondary" @click="agentModalMode = 'regen'">{{ $t('step2.regenerateAgent') }}</button>
|
<button class="btn-secondary" @click="agentModalMode = 'regen'">{{ $t('step2.regenerateAgent') }}</button>
|
||||||
<button class="btn-danger" @click="confirmDeleteAgent(selectedAgent); closeAgentModal()">{{ $t('step2.deleteAgent') }}</button>
|
<button class="btn-danger" @click="confirmDeleteAgent(selectedAgent)">{{ $t('step2.deleteAgent') }}</button>
|
||||||
<button class="btn-primary" @click="agentModalMode = 'edit'">{{ $t('step2.editAgent') }}</button>
|
<button class="btn-primary" @click="agentModalMode = 'edit'">{{ $t('step2.editAgent') }}</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -1189,6 +1189,7 @@ const loadPreparedData = async () => {
|
||||||
// ---- Fase A/B helpers ----
|
// ---- Fase A/B helpers ----
|
||||||
|
|
||||||
const pollTaskUntilDone = async (taskId, onComplete, intervalMs = 2000) => {
|
const pollTaskUntilDone = async (taskId, onComplete, intervalMs = 2000) => {
|
||||||
|
if (!taskId) { onComplete && onComplete(); return }
|
||||||
return new Promise((resolve) => {
|
return new Promise((resolve) => {
|
||||||
const interval = setInterval(async () => {
|
const interval = setInterval(async () => {
|
||||||
try {
|
try {
|
||||||
|
|
@ -1243,9 +1244,14 @@ const saveAgent = async () => {
|
||||||
|
|
||||||
const confirmDeleteAgent = async (agent) => {
|
const confirmDeleteAgent = async (agent) => {
|
||||||
if (!confirm(t('step2.deleteAgentConfirm'))) return
|
if (!confirm(t('step2.deleteAgentConfirm'))) return
|
||||||
const res = await deleteAgent(props.simulationId, agent.user_id)
|
try {
|
||||||
if (res.data?.success) {
|
const res = await deleteAgent(props.simulationId, agent.user_id)
|
||||||
profiles.value = profiles.value.filter(p => p.user_id !== agent.user_id)
|
if (res.data?.success) {
|
||||||
|
profiles.value = profiles.value.filter(p => p.user_id !== agent.user_id)
|
||||||
|
closeAgentModal()
|
||||||
|
}
|
||||||
|
} catch (err) {
|
||||||
|
addLog(`Delete failed: ${err.message}`)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue