Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

fix(artifacts): a saved version the card cannot show is a success

Sanil0e4e69d3e3f3
diff --git a/app/src/features/conversations/aui/ArtifactCardAdapter.tsx b/app/src/features/conversations/aui/ArtifactCardAdapter.tsx
index d4eeb988b6..30b662f8c0 100644
--- a/app/src/features/conversations/aui/ArtifactCardAdapter.tsx
+++ b/app/src/features/conversations/aui/ArtifactCardAdapter.tsx
@@ -40,6 +40,9 @@ export interface ArtifactCardAdapterProps {
onOpenPreview?: (artifactId: string) => void;
}
+/** The core's prefix for a version saved but not shown (`production::SAVED_NOT_SHOWN`). */
+export const SAVED_NOT_SHOWN = 'saved-not-shown:';
+
export function ArtifactCardAdapter({
artifact,
onRetry,
@@ -48,12 +51,20 @@ export function ArtifactCardAdapter({
const { t } = useT();
const generating = artifact.status === 'in_progress';
const isReady = artifact.status === 'ready';
+ // The version was saved, but its file in the files folder was not updated:
+ // the artifact opens (the preview reads the saved version) and there is
+ // nothing to retry.
+ const savedNotShown =
+ artifact.status === 'failed' && (artifact.error ?? '').startsWith(SAVED_NOT_SHOWN);
const meta =
isReady && artifact.sizeBytes != null
? `${t('chat.artifact.ready')} · ${formatFileSize(artifact.sizeBytes)}`
- : artifact.status === 'failed'
- ? t('chat.artifact.failed')
- : '';
+ : savedNotShown
+ ? t('chat.artifact.savedNotShown')
+ : artifact.status === 'failed'
+ ? t('chat.artifact.failed')
+ : '';
+ const canOpen = isReady || savedNotShown;
// The card's own button is the one control that opens the preview.
return (
@@ -65,9 +76,9 @@ export function ArtifactCardAdapter({
words={0}
writingLabel={t('conversations.tools.working')}
icon={KIND_ICONS[artifact.kind]}
- onOpen={isReady && onOpenPreview ? () => onOpenPreview(artifact.artifactId) : undefined}
+ onOpen={canOpen && onOpenPreview ? () => onOpenPreview(artifact.artifactId) : undefined}
/>
- {artifact.status === 'failed' && onRetry ? (
+ {artifact.status === 'failed' && !savedNotShown && onRetry ? (
<Button
variant="secondary"
size="xs"
diff --git a/app/src/features/conversations/aui/__tests__/ArtifactCardAdapter.test.tsx b/app/src/features/conversations/aui/__tests__/ArtifactCardAdapter.test.tsx
index 5bb930e904..6d40202223 100644
--- a/app/src/features/conversations/aui/__tests__/ArtifactCardAdapter.test.tsx
+++ b/app/src/features/conversations/aui/__tests__/ArtifactCardAdapter.test.tsx
@@ -3,7 +3,7 @@ import userEvent from '@testing-library/user-event';
import { describe, expect, it, vi } from 'vitest';
import type { ArtifactSnapshot } from '../../../../store/chatRuntimeSlice';
-import { ArtifactCardAdapter } from '../ArtifactCardAdapter';
+import { ArtifactCardAdapter, SAVED_NOT_SHOWN } from '../ArtifactCardAdapter';
describe('ArtifactCardAdapter', () => {
it('renders the generating (in_progress) state', () => {
@@ -60,4 +60,26 @@ describe('ArtifactCardAdapter', () => {
render(<ArtifactCardAdapter artifact={artifact} />);
expect(screen.queryByRole('button')).toBeNull();
});
+
+ it('a saved version the card could not show says so, opens, and offers no Retry', async () => {
+ const artifact: ArtifactSnapshot = {
+ artifactId: 'a-3',
+ kind: 'document',
+ title: 'Report',
+ status: 'failed',
+ error: `${SAVED_NOT_SHOWN} version 2 is saved, but the file could not be written`,
+ updatedAt: 0,
+ };
+ const onRetry = vi.fn();
+ const onOpenPreview = vi.fn();
+ render(
+ <ArtifactCardAdapter artifact={artifact} onRetry={onRetry} onOpenPreview={onOpenPreview} />
+ );
+ expect(screen.getByText(/Saved, but not updated in your Files folder/)).toBeTruthy();
+ expect(screen.queryByText('Retry')).toBeNull();
+ // Its one button opens the preview, which reads the saved version.
+ await userEvent.click(screen.getByRole('button'));
+ expect(onOpenPreview).toHaveBeenCalledWith('a-3');
+ expect(onRetry).not.toHaveBeenCalled();
+ });
});
diff --git a/app/src/lib/i18n/ar.ts b/app/src/lib/i18n/ar.ts
index 72bf7ab218..8549308d28 100644
--- a/app/src/lib/i18n/ar.ts
+++ b/app/src/lib/i18n/ar.ts
@@ -3313,6 +3313,7 @@ const messages: TranslationMap = {
// Chat: agent-generated artifacts (#2779)
'chat.artifact.ready': 'جاهز',
'chat.artifact.failed': 'فشل الإنشاء',
+ 'chat.artifact.savedNotShown': 'تم الحفظ، لكن لم يُحدَّث في مجلد الملفات',
'chat.artifact.download': 'تنزيل',
'chat.artifact.downloading': 'جارٍ التنزيل…',
'chat.artifact.download_failed': 'فشل التنزيل: {reason}',
diff --git a/app/src/lib/i18n/bn.ts b/app/src/lib/i18n/bn.ts
index 3d24192b6c..78ffb3864f 100644
--- a/app/src/lib/i18n/bn.ts
+++ b/app/src/lib/i18n/bn.ts
@@ -3381,6 +3381,7 @@ const messages: TranslationMap = {
// Chat: agent-generated artifacts (#2779)
'chat.artifact.ready': 'প্রস্তুত',
'chat.artifact.failed': 'তৈরি ব্যর্থ হয়েছে',
+ 'chat.artifact.savedNotShown': 'সংরক্ষিত, তবে আপনার Files ফোল্ডারে আপডেট হয়নি',
'chat.artifact.download': 'ডাউনলোড',
'chat.artifact.downloading': 'ডাউনলোড হচ্ছে…',
'chat.artifact.download_failed': 'ডাউনলোড ব্যর্থ: {reason}',
diff --git a/app/src/lib/i18n/de.ts b/app/src/lib/i18n/de.ts
index 19320767f1..9a141f6cf6 100644
--- a/app/src/lib/i18n/de.ts
+++ b/app/src/lib/i18n/de.ts
@@ -3482,6 +3482,7 @@ const messages: TranslationMap = {
// Chat: agent-generated artifacts (#2779)
'chat.artifact.ready': 'Bereit',
'chat.artifact.failed': 'Erstellung fehlgeschlagen',
+ 'chat.artifact.savedNotShown': 'Gespeichert, aber nicht in deinem Files-Ordner aktualisiert',
'chat.artifact.download': 'Herunterladen',
'chat.artifact.downloading': 'Wird heruntergeladen…',
'chat.artifact.download_failed': 'Download fehlgeschlagen: {reason}',
diff --git a/app/src/lib/i18n/en.ts b/app/src/lib/i18n/en.ts
index a17922b36e..b81a6277bf 100644
--- a/app/src/lib/i18n/en.ts
+++ b/app/src/lib/i18n/en.ts
@@ -3948,6 +3948,7 @@ const en: TranslationMap = {
// Chat: agent-generated artifacts (#2779)
'chat.artifact.ready': 'Ready',
'chat.artifact.failed': 'Generation failed',
+ 'chat.artifact.savedNotShown': 'Saved, but not updated in your Files folder',
'chat.artifact.download': 'Download',
'chat.artifact.downloading': 'Downloading…',
'chat.artifact.download_failed': 'Download failed: {reason}',
diff --git a/app/src/lib/i18n/es.ts b/app/src/lib/i18n/es.ts
index 140f233419..c372445bf8 100644
--- a/app/src/lib/i18n/es.ts
+++ b/app/src/lib/i18n/es.ts
@@ -3450,6 +3450,7 @@ const messages: TranslationMap = {
// Chat: agent-generated artifacts (#2779)
'chat.artifact.ready': 'Listo',
'chat.artifact.failed': 'Error al generar',
+ 'chat.artifact.savedNotShown': 'Guardado, pero no se actualizó en tu carpeta Files',
'chat.artifact.download': 'Descargar',
'chat.artifact.downloading': 'Descargando…',
'chat.artifact.download_failed': 'Error al descargar: {reason}',
diff --git a/app/src/lib/i18n/fr.ts b/app/src/lib/i18n/fr.ts
index 9b6672bc3f..5c45f53b73 100644
--- a/app/src/lib/i18n/fr.ts
+++ b/app/src/lib/i18n/fr.ts
@@ -3464,6 +3464,7 @@ const messages: TranslationMap = {
// Chat: agent-generated artifacts (#2779)
'chat.artifact.ready': 'Prêt',
'chat.artifact.failed': 'Échec de la génération',
+ 'chat.artifact.savedNotShown': 'Enregistré, mais pas mis à jour dans votre dossier Files',
'chat.artifact.download': 'Télécharger',
'chat.artifact.downloading': 'Téléchargement…',
'chat.artifact.download_failed': 'Échec du téléchargement : {reason}',
diff --git a/app/src/lib/i18n/hi.ts b/app/src/lib/i18n/hi.ts
index 617b68bc7a..3c2dcd73cc 100644
--- a/app/src/lib/i18n/hi.ts
+++ b/app/src/lib/i18n/hi.ts
@@ -3384,6 +3384,7 @@ const messages: TranslationMap = {
// Chat: agent-generated artifacts (#2779)
'chat.artifact.ready': 'तैयार',
'chat.artifact.failed': 'निर्माण विफल',
+ 'chat.artifact.savedNotShown': 'सहेजा गया, लेकिन आपके Files फ़ोल्डर में अपडेट नहीं हुआ',
'chat.artifact.download': 'डाउनलोड',
'chat.artifact.downloading': 'डाउनलोड हो रहा है…',
'chat.artifact.download_failed': 'डाउनलोड विफल: {reason}',
diff --git a/app/src/lib/i18n/id.ts b/app/src/lib/i18n/id.ts
index 62e0a4f824..678c7cfb8f 100644
--- a/app/src/lib/i18n/id.ts
+++ b/app/src/lib/i18n/id.ts
@@ -3409,6 +3409,7 @@ const messages: TranslationMap = {
// Chat: agent-generated artifacts (#2779)
'chat.artifact.ready': 'Siap',
'chat.artifact.failed': 'Gagal dibuat',
+ 'chat.artifact.savedNotShown': 'Tersimpan, tetapi tidak diperbarui di folder Files Anda',
'chat.artifact.download': 'Unduh',
'chat.artifact.downloading': 'Mengunduh…',
'chat.artifact.download_failed': 'Unduhan gagal: {reason}',
diff --git a/app/src/lib/i18n/it.ts b/app/src/lib/i18n/it.ts
index 4ddb6666fc..7d1471d799 100644
--- a/app/src/lib/i18n/it.ts
+++ b/app/src/lib/i18n/it.ts
@@ -3443,6 +3443,7 @@ const messages: TranslationMap = {
// Chat: agent-generated artifacts (#2779)
'chat.artifact.ready': 'Pronto',
'chat.artifact.failed': 'Generazione fallita',
+ 'chat.artifact.savedNotShown': 'Salvato, ma non aggiornato nella cartella Files',
'chat.artifact.download': 'Scarica',
'chat.artifact.downloading': 'Scaricamento…',
'chat.artifact.download_failed': 'Download fallito: {reason}',
diff --git a/app/src/lib/i18n/ja.ts b/app/src/lib/i18n/ja.ts
index 51059e6e1a..6035e46464 100644
--- a/app/src/lib/i18n/ja.ts
+++ b/app/src/lib/i18n/ja.ts
@@ -3983,6 +3983,7 @@ const messages: TranslationMap = {
// Chat: agent-generated artifacts (#2779)
'chat.artifact.ready': '準備完了',
'chat.artifact.failed': '生成に失敗しました',
+ 'chat.artifact.savedNotShown': '保存しましたが、Files フォルダーでは更新されていません',
'chat.artifact.download': 'ダウンロード',
'chat.artifact.downloading': 'ダウンロード中…',
'chat.artifact.download_failed': 'ダウンロードに失敗しました: {reason}',
diff --git a/app/src/lib/i18n/ko.ts b/app/src/lib/i18n/ko.ts
index 79b9da871d..749849bbce 100644
--- a/app/src/lib/i18n/ko.ts
+++ b/app/src/lib/i18n/ko.ts
@@ -3347,6 +3347,7 @@ const messages: TranslationMap = {
// Chat: agent-generated artifacts (#2779)
'chat.artifact.ready': '준비됨',
'chat.artifact.failed': '생성 실패',
+ 'chat.artifact.savedNotShown': '저장되었지만 Files 폴더에는 업데이트되지 않았습니다',
'chat.artifact.download': '다운로드',
'chat.artifact.downloading': '다운로드 중…',
'chat.artifact.download_failed': '다운로드 실패: {reason}',
diff --git a/app/src/lib/i18n/pl.ts b/app/src/lib/i18n/pl.ts
index 9e95f02700..758115c36b 100644
--- a/app/src/lib/i18n/pl.ts
+++ b/app/src/lib/i18n/pl.ts
@@ -3433,6 +3433,7 @@ const messages: TranslationMap = {
// Chat: agent-generated artifacts (#2779)
'chat.artifact.ready': 'Gotowe',
'chat.artifact.failed': 'Generowanie nie powiodło się',
+ 'chat.artifact.savedNotShown': 'Zapisano, ale nie zaktualizowano w folderze Files',
'chat.artifact.download': 'Pobierz',
'chat.artifact.downloading': 'Pobieranie…',
'chat.artifact.download_failed': 'Pobieranie nie powiodło się: {reason}',
diff --git a/app/src/lib/i18n/pt.ts b/app/src/lib/i18n/pt.ts
index dca8ccc008..5561223724 100644
--- a/app/src/lib/i18n/pt.ts
+++ b/app/src/lib/i18n/pt.ts
@@ -3430,6 +3430,7 @@ const messages: TranslationMap = {
// Chat: agent-generated artifacts (#2779)
'chat.artifact.ready': 'Pronto',
'chat.artifact.failed': 'Falha ao gerar',
+ 'chat.artifact.savedNotShown': 'Salvo, mas não atualizado na sua pasta Files',
'chat.artifact.download': 'Baixar',
'chat.artifact.downloading': 'Baixando…',
'chat.artifact.download_failed': 'Falha no download: {reason}',
diff --git a/app/src/lib/i18n/ru.ts b/app/src/lib/i18n/ru.ts
index b9863fa385..a2b0c4876b 100644
--- a/app/src/lib/i18n/ru.ts
+++ b/app/src/lib/i18n/ru.ts
@@ -3422,6 +3422,7 @@ const messages: TranslationMap = {
// Chat: agent-generated artifacts (#2779)
'chat.artifact.ready': 'Готово',
'chat.artifact.failed': 'Сбой генерации',
+ 'chat.artifact.savedNotShown': 'Сохранено, но не обновлено в папке Files',
'chat.artifact.download': 'Скачать',
'chat.artifact.downloading': 'Скачивание…',
'chat.artifact.download_failed': 'Сбой скачивания: {reason}',
diff --git a/app/src/lib/i18n/tr.ts b/app/src/lib/i18n/tr.ts
index 20556b5231..5345ab4e44 100644
--- a/app/src/lib/i18n/tr.ts
+++ b/app/src/lib/i18n/tr.ts
@@ -3644,6 +3644,7 @@ const messages: TranslationMap = {
'workflows.phase.toolScope.allow': 'İzin ver',
'chat.artifact.ready': 'Hazır',
'chat.artifact.failed': 'Oluşturma başarısız',
+ 'chat.artifact.savedNotShown': 'Kaydedildi, ancak Files klasörünüzde güncellenmedi',
'chat.artifact.download': 'İndir',
'chat.artifact.downloading': 'İndiriliyor…',
'chat.artifact.download_failed': 'İndirme başarısız: {reason}',
diff --git a/app/src/lib/i18n/zh-CN.ts b/app/src/lib/i18n/zh-CN.ts
index 8ba4204350..3f26156888 100644
--- a/app/src/lib/i18n/zh-CN.ts
+++ b/app/src/lib/i18n/zh-CN.ts
@@ -3188,6 +3188,7 @@ const messages: TranslationMap = {
// Chat:agent-generated artifacts (#2779)
'chat.artifact.ready': '已就绪',
'chat.artifact.failed': '生成失败',
+ 'chat.artifact.savedNotShown': '已保存,但未在你的“文件”文件夹中更新',
'chat.artifact.download': '下载',
'chat.artifact.downloading': '下载中…',
'chat.artifact.download_failed': '下载失败:{reason}',
diff --git a/crates/openhuman-core/src/agent/artifacts/production.rs b/crates/openhuman-core/src/agent/artifacts/production.rs
index 704bf6f3de..18e303a424 100644
--- a/crates/openhuman-core/src/agent/artifacts/production.rs
+++ b/crates/openhuman-core/src/agent/artifacts/production.rs
@@ -26,6 +26,11 @@ use super::tiny_store::{artifacts_service, legacy_kind_for_extension};
use super::types::ArtifactKind as LegacyArtifactKind;
use crate::security::approval::ApprovalChatContext;
+/// Starts the card's failure reason when a version was recorded but the card
+/// could not show it (its file in the files folder was not updated). The UI
+/// keys on it to say so, instead of "generation failed".
+pub const SAVED_NOT_SHOWN: &str = "saved-not-shown:";
+
/// A file being produced as an artifact.
pub struct Production {
artifacts: Artifacts,
@@ -153,20 +158,35 @@ impl Production {
)
.await;
match saved {
- Ok(saved) => {
- let reason = match (
- saved.notice,
- saved.record.latest().and_then(|v| v.file.clone()),
- ) {
- (None, Some(file)) => return Ok(file.size_bytes),
- (Some(notice), _) => notice,
- (None, None) => "the recorded version has no file".to_string(),
- };
- // The version is recorded; only the card could not follow.
- let reason = format!("failed to finalize artifact: {reason}");
- self.fail_card(&reason).await;
- Err(reason)
- }
+ Ok(saved) => match (
+ saved.notice,
+ saved.record.latest().and_then(|v| v.file.clone()),
+ ) {
+ (None, Some(file)) => Ok(file.size_bytes),
+ // The version is recorded, so the production succeeded; only
+ // the card (and the file in the files folder) could not follow.
+ // The card says exactly that.
+ (Some(notice), Some(file)) => {
+ tracing::warn!(
+ target: "tiny-artifacts",
+ artifact_id = %self.id,
+ version = saved.version,
+ notice = %notice,
+ "[artifacts] version saved but not shown"
+ );
+ self.fail_card(&format!(
+ "{SAVED_NOT_SHOWN} version {} is saved, but {notice}",
+ saved.version
+ ))
+ .await;
+ Ok(file.size_bytes)
+ }
+ (_, None) => {
+ let reason = "failed to finalize artifact: the recorded version has no file";
+ self.fail_card(reason).await;
+ Err(reason.to_string())
+ }
+ },
// Nothing was recorded: end it as any failed production ends.
Err(err) => {
let reason = format!("failed to finalize artifact: {err}");
diff --git a/crates/openhuman-core/src/agent/artifacts/production_tests.rs b/crates/openhuman-core/src/agent/artifacts/production_tests.rs
index d74357fa7d..5bd907b072 100644
--- a/crates/openhuman-core/src/agent/artifacts/production_tests.rs
+++ b/crates/openhuman-core/src/agent/artifacts/production_tests.rs
@@ -217,3 +217,46 @@ async fn a_completion_that_records_nothing_fails_the_record_too() {
let card = get_artifact(&workspace, production.id()).await.unwrap();
assert_eq!(card.status, CardStatus::Failed);
}
+
+#[cfg(unix)]
+#[tokio::test]
+async fn a_saved_version_the_card_cannot_show_succeeds_and_says_so() {
+ use std::os::unix::fs::PermissionsExt;
+
+ let (workspace, files) = temp_dirs();
+ let production = Production::start(
+ &workspace,
+ FileRoots::new(&files),
+ ArtifactKind::File,
+ "Quarterly Deck",
+ "pptx",
+ None,
+ None,
+ None,
+ )
+ .await
+ .unwrap();
+ tokio::fs::write(production.path(), b"deck-v1")
+ .await
+ .unwrap();
+ // The card's file cannot be written: the version is recorded (from its
+ // kept copy), but the card cannot show it.
+ let visible = production.path().to_path_buf();
+ std::fs::set_permissions(&visible, std::fs::Permissions::from_mode(0o444)).unwrap();
+
+ let result = production.complete().await;
+ std::fs::set_permissions(&visible, std::fs::Permissions::from_mode(0o644)).unwrap();
+ assert_eq!(result.unwrap(), 7);
+
+ let record = versioned_store(&workspace)
+ .get(production.id())
+ .await
+ .unwrap()
+ .unwrap();
+ assert_eq!(record.status, RecordStatus::Ready);
+ assert_eq!(record.versions.len(), 1);
+ let card = get_artifact(&workspace, production.id()).await.unwrap();
+ assert_eq!(card.status, CardStatus::Failed);
+ let error = card.error.unwrap_or_default();
+ assert!(error.starts_with(SAVED_NOT_SHOWN), "{error}");
+}