Fiks: prompt-redigering toggle, AI-pulsering ved feil, error-status
- Rediger-knappen i prompt-seksjonen fungerer som Avbryt når editoren er åpen - Fjernet separat Avbryt-knapp fra prompt-editor footer - pollJob sjekker nå også 'error'-status (ikke bare completed/failed) - Worker rydder ai_processing-flagget fra metadata ved feil Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
f7308d21e8
commit
c32b772293
3 changed files with 31 additions and 4 deletions
|
|
@ -78,7 +78,7 @@
|
||||||
const res = await fetch(`/api/jobs/${jobId}`);
|
const res = await fetch(`/api/jobs/${jobId}`);
|
||||||
if (!res.ok) { clearInterval(interval); return; }
|
if (!res.ok) { clearInterval(interval); return; }
|
||||||
const job = await res.json();
|
const job = await res.json();
|
||||||
if (job.status === 'completed' || job.status === 'failed') {
|
if (job.status === 'completed' || job.status === 'failed' || job.status === 'error') {
|
||||||
clearInterval(interval);
|
clearInterval(interval);
|
||||||
await chat?.refresh();
|
await chat?.refresh();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1187,6 +1187,8 @@
|
||||||
<span class="status-saving">...</span>
|
<span class="status-saving">...</span>
|
||||||
{:else if saved === prompt.action}
|
{:else if saved === prompt.action}
|
||||||
<span class="status-saved">OK</span>
|
<span class="status-saved">OK</span>
|
||||||
|
{:else if editingPrompt === prompt.action}
|
||||||
|
<button class="toggle-btn" onclick={cancelEditPrompt}>Avbryt</button>
|
||||||
{:else}
|
{:else}
|
||||||
<button class="toggle-btn" onclick={() => startEditPrompt(prompt)}>Rediger</button>
|
<button class="toggle-btn" onclick={() => startEditPrompt(prompt)}>Rediger</button>
|
||||||
{/if}
|
{/if}
|
||||||
|
|
@ -1212,7 +1214,6 @@
|
||||||
<div class="prompt-editor-footer">
|
<div class="prompt-editor-footer">
|
||||||
<span class="prompt-char-count">{editPromptText.length} tegn</span>
|
<span class="prompt-char-count">{editPromptText.length} tegn</span>
|
||||||
<div class="prompt-editor-actions">
|
<div class="prompt-editor-actions">
|
||||||
<button class="toggle-btn" onclick={cancelEditPrompt}>Avbryt</button>
|
|
||||||
<button class="add-btn" onclick={() => savePrompt(prompt)}>Lagre</button>
|
<button class="add-btn" onclick={() => savePrompt(prompt)}>Lagre</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -73,6 +73,34 @@ impl JobHandler for AiTextProcessHandler {
|
||||||
.parse()
|
.parse()
|
||||||
.context("Ugyldig message_id UUID")?;
|
.context("Ugyldig message_id UUID")?;
|
||||||
|
|
||||||
|
// Wrapper som rydder ai_processing-flagget ved feil
|
||||||
|
let result = self.handle_inner(pool, workspace_id, job_id, payload, message_id).await;
|
||||||
|
if result.is_err() {
|
||||||
|
let _ = sqlx::query(
|
||||||
|
r#"
|
||||||
|
UPDATE messages
|
||||||
|
SET metadata = COALESCE(metadata, '{}'::jsonb) - 'ai_processing'
|
||||||
|
WHERE id = $1
|
||||||
|
"#,
|
||||||
|
)
|
||||||
|
.bind(message_id)
|
||||||
|
.execute(pool)
|
||||||
|
.await;
|
||||||
|
}
|
||||||
|
result
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl AiTextProcessHandler {
|
||||||
|
async fn handle_inner(
|
||||||
|
&self,
|
||||||
|
pool: &PgPool,
|
||||||
|
workspace_id: &Uuid,
|
||||||
|
job_id: &Uuid,
|
||||||
|
payload: &Value,
|
||||||
|
message_id: Uuid,
|
||||||
|
) -> anyhow::Result<Option<Value>> {
|
||||||
|
|
||||||
let action = payload
|
let action = payload
|
||||||
.get("action")
|
.get("action")
|
||||||
.and_then(|v| v.as_str())
|
.and_then(|v| v.as_str())
|
||||||
|
|
@ -262,9 +290,7 @@ impl JobHandler for AiTextProcessHandler {
|
||||||
}
|
}
|
||||||
})))
|
})))
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
impl AiTextProcessHandler {
|
|
||||||
/// Oppdater meldingen i SpacetimeDB via edit_message reducer,
|
/// Oppdater meldingen i SpacetimeDB via edit_message reducer,
|
||||||
/// slik at frontend (som leser fra SpacetimeDB) ser AI-resultatet.
|
/// slik at frontend (som leser fra SpacetimeDB) ser AI-resultatet.
|
||||||
async fn update_spacetimedb(
|
async fn update_spacetimedb(
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue