fix(assistant): unlock configuration after failed request

This commit is contained in:
Lucio Lelii 2026-09-01 16:32:11 +02:00
parent d05a661473
commit 8b34f49056
3 changed files with 9 additions and 19 deletions

View File

@ -251,7 +251,7 @@
}
.assistant-advanced-toggle,
.assistant-new-session {
.assistant-advanced-toggle {
justify-self: start;
border: 0;
padding: 0;

View File

@ -45,11 +45,6 @@
<p class="assistant-label">Configurazione assistente</p>
<p class="assistant-copy">Le credenziali dei provider sono gestite dal backend.</p>
</div>
@if (configurationLocked()) {
<button type="button" mat-stroked-button class="assistant-new-session" [disabled]="assistantBusy()" (click)="createNewSession()">
Nuova sessione
</button>
}
</div>
<mat-checkbox
@ -60,7 +55,7 @@
</mat-checkbox>
@if (configurationLocked()) {
<p class="assistant-meta">La configurazione LLM è fissata per questa sessione. Crea una nuova sessione per modificarla.</p>
<p class="assistant-meta">La configurazione LLM è fissata per questa sessione.</p>
}
@if (!useDefaultConfiguration()) {

View File

@ -277,18 +277,6 @@ export class FlowAssistant implements OnInit, OnDestroy {
this.persistSnapshot();
}
createNewSession() {
if (this.assistantBusy() || !this.configurationValid()) return;
this.stopPolling();
this.currentCall.set(null);
this.sessionState.set(null);
this.localMessages.set([]);
this.assistantErrorMessage.set(null);
this.lastFailedPrompt.set(null);
this.lastSubmittedPrompt.set('');
void this.openSession();
}
useStarter(prompt: string) {
this.prompt.set(prompt);
this.persistSnapshot();
@ -388,6 +376,7 @@ export class FlowAssistant implements OnInit, OnDestroy {
error: (err) => {
console.error('Assistant flow action failed', err);
this.requestPending.set(false);
this.discardFailedSession();
this.handleAssistantErrorWithRetry(normalizedContent, this.backendErrorMessage(err));
}
});
@ -505,6 +494,12 @@ export class FlowAssistant implements OnInit, OnDestroy {
this.syncDraftToEditor(result.flow);
}
private discardFailedSession() {
this.stopPolling();
this.currentCall.set(null);
this.sessionState.set(null);
}
private backendErrorMessage(error: unknown): string {
const value = error as { error?: unknown; message?: unknown };
const payload = value?.error;