From 83d48a19a3260a8381a5c9b0fea191280247b66a Mon Sep 17 00:00:00 2001 From: Matheus Marques Botelho Date: Wed, 18 Nov 2026 01:57:33 -0300 Subject: [PATCH 1/3] fix(server,web): session import reports deferred conversations apart from failures --- .../src/project/AgentSessionImporter.test.ts | 34 +++--- .../src/project/AgentSessionImporter.ts | 8 +- .../server/src/project/AgentSessionScanner.ts | 14 +-- .../src/components/onboarding/WelcomePage.tsx | 30 ++--- apps/web/src/i18n/translations/de.json | 10 +- apps/web/src/i18n/translations/en.json | 10 +- apps/web/src/i18n/translations/es.json | 10 +- apps/web/src/i18n/translations/fr.json | 10 +- apps/web/src/i18n/translations/ja.json | 10 +- apps/web/src/i18n/translations/ko.json | 10 +- apps/web/src/i18n/translations/pt-BR.json | 10 +- apps/web/src/i18n/translations/ru.json | 10 +- apps/web/src/i18n/translations/sv.json | 10 +- apps/web/src/i18n/translations/zh.json | 10 +- .../onboarding/projectImport.logic.test.ts | 31 ++++++ .../web/src/onboarding/projectImport.logic.ts | 60 ++++++++++ docs/user/welcome-page.md | 6 +- packages/contracts/src/agentSessions.ts | 2 + ...reports-deferred-threads-separately.e2e.ts | 105 ++++++++++++++++++ 19 files changed, 304 insertions(+), 86 deletions(-) create mode 100644 scripts/scenarios/import-reports-deferred-threads-separately.e2e.ts diff --git a/apps/server/src/project/AgentSessionImporter.test.ts b/apps/server/src/project/AgentSessionImporter.test.ts index 18c0946144d4a..cb19d0f319596 100644 --- a/apps/server/src/project/AgentSessionImporter.test.ts +++ b/apps/server/src/project/AgentSessionImporter.test.ts @@ -327,7 +327,7 @@ it.effect( unownedPi, ]); - expect(yield* importer.run).toEqual({ importedCount: 3, skippedCount: 0 }); + expect(yield* importer.run).toEqual({ importedCount: 3, skippedCount: 0, deferredCount: 0 }); for (const source of [active, archived, deleted, ownedPi]) { const threadId = importId(source); expect(yield* Effect.option(projections.getThread(threadId))).toEqual(Option.none()); @@ -409,7 +409,7 @@ it.effect("tolerates a missing transcript owner but propagates failed ownership source: source.source, }); const importer = yield* makeImporter([source]); - expect(yield* importer.run).toEqual({ importedCount: 1, skippedCount: 0 }); + expect(yield* importer.run).toEqual({ importedCount: 1, skippedCount: 0, deferredCount: 0 }); yield* sql`UPDATE orchestration_v2_projection_threads SET payload_json = '{}' WHERE thread_id = ${threadId}`; expect(yield* Effect.flip(importer.run)).toMatchObject({ @@ -440,8 +440,12 @@ it.effect("rechecks ownership after the import reaches the commit transaction", // Commit ownership after all pre-transaction reads, before the import acquires SQLite. const ownerId = yield* seedOwner(source); yield* Deferred.succeed(continueTransaction, undefined); - expect(yield* Fiber.join(pending)).toEqual({ importedCount: 0, skippedCount: 0 }); - expect(yield* importer.run).toEqual({ importedCount: 0, skippedCount: 0 }); + expect(yield* Fiber.join(pending)).toEqual({ + importedCount: 0, + skippedCount: 0, + deferredCount: 0, + }); + expect(yield* importer.run).toEqual({ importedCount: 0, skippedCount: 0, deferredCount: 0 }); const projections = yield* ProjectionStore.ProjectionStoreV2; const events = yield* EventStore.EventStoreV2; const runtimes = yield* ProviderSessionRuntime.ProviderSessionRuntimeRepository; @@ -468,7 +472,7 @@ it.effect( const threadId = importId(source); const importer = yield* makeImporter([source]); yield* sql`CREATE TEMP TRIGGER fail_import BEFORE INSERT ON orchestration_events WHEN NEW.event_type = 'message.updated' BEGIN SELECT RAISE(ABORT, 'test publication failure'); END`; - expect(yield* importer.run).toEqual({ importedCount: 0, skippedCount: 1 }); + expect(yield* importer.run).toEqual({ importedCount: 0, skippedCount: 1, deferredCount: 0 }); expect(yield* events.read({ threadId }).pipe(Stream.runCollect)).toEqual([]); expect(yield* Effect.option(projections.getThread(threadId))).toEqual(Option.none()); expect(yield* runtimes.list()).toEqual([]); @@ -476,15 +480,15 @@ it.effect( yield* sql`DROP TRIGGER fail_import`; yield* sql`CREATE TEMP TRIGGER fail_runtime BEFORE INSERT ON provider_session_runtime BEGIN SELECT RAISE(ABORT, 'test runtime failure'); END`; - expect(yield* importer.run).toEqual({ importedCount: 0, skippedCount: 1 }); + expect(yield* importer.run).toEqual({ importedCount: 0, skippedCount: 1, deferredCount: 0 }); const committed = yield* events.read({ threadId }).pipe(Stream.runCollect); expect(committed).toHaveLength(6); expect(importer.published).toHaveLength(6); expect(yield* runtimes.list()).toEqual([]); yield* sql`DROP TRIGGER fail_runtime`; - expect(yield* importer.run).toEqual({ importedCount: 0, skippedCount: 0 }); - expect(yield* importer.run).toEqual({ importedCount: 0, skippedCount: 0 }); + expect(yield* importer.run).toEqual({ importedCount: 0, skippedCount: 0, deferredCount: 0 }); + expect(yield* importer.run).toEqual({ importedCount: 0, skippedCount: 0, deferredCount: 0 }); expect(yield* events.read({ threadId }).pipe(Stream.runCollect)).toEqual(committed); expect(importer.published).toHaveLength(6); expect( @@ -511,7 +515,7 @@ it.effect("counts only new threads when re-importing cached and recovered transc ); const recovered = candidate(CODEX_MODEL_SELECTION, "recovered"); const initial = yield* makeImporter([cached, recovered]); - expect(yield* initial.run).toEqual({ importedCount: 2, skippedCount: 0 }); + expect(yield* initial.run).toEqual({ importedCount: 2, skippedCount: 0, deferredCount: 0 }); const before = yield* events.read({ threadId: importId(recovered) }).pipe(Stream.runCollect); // The file changed on disk but still holds the imported messages. recovered.source.size += 100; @@ -526,7 +530,7 @@ it.effect("counts only new threads when re-importing cached and recovered transc { _tag: "Skipped" }, ]); - expect(yield* repeated.run).toEqual({ importedCount: 1, skippedCount: 1 }); + expect(yield* repeated.run).toEqual({ importedCount: 1, skippedCount: 1, deferredCount: 0 }); expect(yield* events.read({ threadId: importId(recovered) }).pipe(Stream.runCollect)).toEqual( before, ); @@ -552,7 +556,7 @@ it.effect("does not certify new native history after a partial import retry", () const threadId = importId(original); const importer = yield* makeImporter([original]); yield* sql`CREATE TEMP TRIGGER fail_runtime BEFORE INSERT ON provider_session_runtime BEGIN SELECT RAISE(ABORT, 'test runtime failure'); END`; - expect(yield* importer.run).toEqual({ importedCount: 0, skippedCount: 1 }); + expect(yield* importer.run).toEqual({ importedCount: 0, skippedCount: 1, deferredCount: 0 }); yield* sql`DROP TRIGGER fail_runtime`; expect(yield* runtimes.list()).toEqual([]); const continued = candidate(CODEX_MODEL_SELECTION, original.source.providerSessionId); @@ -566,6 +570,7 @@ it.effect("does not certify new native history after a partial import retry", () expect(yield* (yield* makeImporter([continued])).run).toEqual({ importedCount: 0, skippedCount: 1, + deferredCount: 0, }); expect(yield* runtimes.list()).toEqual([]); expect( @@ -589,6 +594,7 @@ it.effect("does not record a changed transcript as imported without its new mess expect(yield* (yield* makeImporter([first])).run).toEqual({ importedCount: 1, skippedCount: 0, + deferredCount: 0, }); const continued = candidate( @@ -952,7 +958,7 @@ it.effect("imports under a policy ceiling in the project's default, kept under t }, ), ); - expect(yield* importer.run).toEqual({ importedCount: 1, skippedCount: 0 }); + expect(yield* importer.run).toEqual({ importedCount: 1, skippedCount: 0, deferredCount: 0 }); expect((yield* projections.getThread(threadId)).runtimeMode).toBe("auto-accept-edits"); expect(Option.getOrThrow(yield* runtimes.getByThreadId({ threadId })).runtimeMode).toBe( "auto-accept-edits", @@ -1041,8 +1047,8 @@ it.effect("repeated imports reach linked-worktree sessions behind the scan budge scanner: Context.get(scannerContext, AgentSessionScanner.AgentSessionScanner), }); - expect(yield* importer.run).toEqual({ importedCount: 100, skippedCount: 1 }); - expect(yield* importer.run).toEqual({ importedCount: 1, skippedCount: 0 }); + expect(yield* importer.run).toEqual({ importedCount: 100, skippedCount: 1, deferredCount: 1 }); + expect(yield* importer.run).toEqual({ importedCount: 1, skippedCount: 0, deferredCount: 0 }); const oldest = yield* ProjectionStore.ProjectionStoreV2.pipe( Effect.flatMap((projections) => projections.getThread(ThreadId.make("import:codex:session-100")), diff --git a/apps/server/src/project/AgentSessionImporter.ts b/apps/server/src/project/AgentSessionImporter.ts index 0f8736986a2df..b875c5c6ee9e3 100644 --- a/apps/server/src/project/AgentSessionImporter.ts +++ b/apps/server/src/project/AgentSessionImporter.ts @@ -266,6 +266,7 @@ const make = Effect.gen(function* () { const importedThreadIds = new Set(); let importedCount = 0; let skippedCount = 0; + let deferredCount = 0; yield* Stream.runForEach(outcomes, (outcome) => Effect.gen(function* () { @@ -273,6 +274,11 @@ const make = Effect.gen(function* () { skippedCount += 1; return; } + if (outcome._tag === "Deferred") { + skippedCount += 1; + deferredCount += 1; + return; + } const source = outcome.source; const threadId = ThreadId.make( `import:${source.providerInstanceId}:${source.providerSessionId}`, @@ -495,7 +501,7 @@ const make = Effect.gen(function* () { }), ); - return { importedCount, skippedCount } satisfies AgentSessionImportResult; + return { importedCount, skippedCount, deferredCount } satisfies AgentSessionImportResult; }); /** diff --git a/apps/server/src/project/AgentSessionScanner.ts b/apps/server/src/project/AgentSessionScanner.ts index 1e300d1fe0410..503f172a5bcc0 100644 --- a/apps/server/src/project/AgentSessionScanner.ts +++ b/apps/server/src/project/AgentSessionScanner.ts @@ -228,7 +228,8 @@ export type AgentSessionRecentThread = } | { readonly _tag: "AlreadyImported"; readonly source: AgentSessionImportSource } | { readonly _tag: "Duplicate"; readonly source: AgentSessionImportSource } - | { readonly _tag: "Skipped" }; + | { readonly _tag: "Skipped" } + | { readonly _tag: "Deferred" }; export class AgentSessionScanner extends Context.Service< AgentSessionScanner, @@ -2131,7 +2132,7 @@ export const make = Effect.gen(function* () { `${candidate.providerInstanceId}\0${transcript.filePath}`, ); if (completed === undefined && (transcriptsRemaining === 0 || bytesRemaining === 0)) { - return Option.some({ _tag: "Skipped" }); + return Option.some({ _tag: "Deferred" }); } const stats = yield* statOption(transcript.filePath); if (Option.isNone(stats) || stats.value.type !== "File") { @@ -2151,13 +2152,12 @@ export const make = Effect.gen(function* () { source: completedSource, }); } - if ( - transcriptsRemaining === 0 || - identity.size > MAX_IMPORTED_TRANSCRIPT_BYTES || - identity.size > bytesRemaining - ) { + if (identity.size > MAX_IMPORTED_TRANSCRIPT_BYTES) { return Option.some({ _tag: "Skipped" }); } + if (transcriptsRemaining === 0 || identity.size > bytesRemaining) { + return Option.some({ _tag: "Deferred" }); + } transcriptsRemaining -= 1; bytesRemaining -= identity.size; const snapshot = yield* readTranscript(transcript.filePath, identity, candidate.source); diff --git a/apps/web/src/components/onboarding/WelcomePage.tsx b/apps/web/src/components/onboarding/WelcomePage.tsx index 5c1b4218117fc..b5f7c4e7079cb 100644 --- a/apps/web/src/components/onboarding/WelcomePage.tsx +++ b/apps/web/src/components/onboarding/WelcomePage.tsx @@ -56,6 +56,7 @@ import { groupOnboardingProjects, partitionOnboardingProjects, onboardingProjectKey, + projectImportWarning, resolveOnboardingLandingProject, isNewOnboardingProject, resolveOnboardingProjectId, @@ -1496,7 +1497,6 @@ function useProjectImport({ ) => Promise; }) { const writableEnvironments = useEnvironmentsWithScope(scans, AuthOrchestrationOperateScope); - const gt = useGT(); const createProject = useAtomCommand(projectEnvironment.create, { reportFailure: false }); const importThreads = useAtomCommand(agentSessionImport, { reportFailure: false }); const importWarningRef = useRef(""); @@ -1620,6 +1620,7 @@ function useProjectImport({ ? selection.filter((candidate) => importedProjects.has(candidate.key)).length : 0; let skippedThreadCount = 0; + let deferredThreadCount = 0; const refreshEnvironments = new Set(); // Resolves false when the run stopped early: a newer run, an unmount, or lost access. const importEach = async () => { @@ -1679,6 +1680,7 @@ function useProjectImport({ (importedThreads.get(candidate.key) ?? 0) + threadImportResult.value.importedCount, ); skippedThreadCount += threadImportResult.value.skippedCount; + deferredThreadCount += threadImportResult.value.deferredCount ?? 0; if (threadImportResult.value.importedCount > 0) { projectsWithImportedHistoryRef.current.set( candidate.key, @@ -1707,27 +1709,11 @@ function useProjectImport({ setIsImporting(false); const importedThreadCount = importedThreadTotal(); if (importedProjectsCount < selection.length) { - if (importedThreadCount > 0 && skippedThreadCount > 0) { - importWarningRef.current = `${gt( - "{count, plural, one {Imported {count} thread.} other {Imported {count} threads.}}", - { count: importedThreadCount }, - )} ${gt( - "{count, plural, one {{count} thread could not be imported.} other {{count} threads could not be imported.}}", - { count: skippedThreadCount }, - )}`; - } else if (skippedThreadCount > 0) { - importWarningRef.current = gt( - "{count, plural, one {{count} thread could not be imported.} other {{count} threads could not be imported.}}", - { count: skippedThreadCount }, - ); - } else if (importedThreadCount > 0) { - importWarningRef.current = gt( - "{count, plural, one {Imported {count} thread. Some thread history could not be imported.} other {Imported {count} threads. Some thread history could not be imported.}}", - { count: importedThreadCount }, - ); - } else { - importWarningRef.current = gt("Could not import thread history."); - } + importWarningRef.current = projectImportWarning({ + imported: importedThreadCount, + failed: skippedThreadCount - deferredThreadCount, + deferred: deferredThreadCount, + }); } finishAfterImport(); }; diff --git a/apps/web/src/i18n/translations/de.json b/apps/web/src/i18n/translations/de.json index 648fd58859dbe..8cf7133a841a8 100644 --- a/apps/web/src/i18n/translations/de.json +++ b/apps/web/src/i18n/translations/de.json @@ -2852,6 +2852,12 @@ "5e4a0e56a0788d86": "Aufgezeichneter Inhalt nachher", "6d5a8b471a561b9d": "Explorer", "83a174f9e78fe2f1": "Dateien", + "ce247a620407cec4": "{count, plural, one {{count} Thread importiert. Ein Teil des Thread-Verlaufs konnte nicht importiert werden.} other {{count} Threads importiert. Ein Teil des Thread-Verlaufs konnte nicht importiert werden.}}", + "a0fd24f965eb070b": "Thread-Verlauf konnte nicht importiert werden.", + "b79e42281b0acc9e": "{count, plural, one {{count} Thread importiert.} other {{count} Threads importiert.}}", + "686dd0744640be73": "{count, plural, one {{count} Thread konnte nicht importiert werden.} other {{count} Threads konnten nicht importiert werden.}}", + "a58e4704fffba164": "{count, plural, one {{count} Thread wurde noch nicht importiert.} other {{count} Threads wurden noch nicht importiert.}}", + "8b8a18b159e8e1de": "Um sie zu importieren, öffne die Willkommensseite erneut über Einstellungen → Info und wähle ihre Projekte unter „Alle prüfen“ aus.", "9c867852bab1ce60": "Die Zwischenablage-API ist beim Kopieren des Fehlerberichts nicht verfügbar.", "a270f51c3f95de49": "Der Fehlerbericht konnte nicht in die Zwischenablage kopiert werden.", "09675b4ac9f858dc": "Ein unerwarteter Router-Fehler ist aufgetreten.", @@ -5939,10 +5945,6 @@ "728b7fa1184ea9c8": "Das Einrichtungsterminal konnte nicht geöffnet werden.", "8769d29d8434e535": "Befehl wird vorbereitet...", "f3889aa139ecefa7": "{agent} installieren", - "b79e42281b0acc9e": "{count, plural, one {{count} Thread importiert.} other {{count} Threads importiert.}}", - "686dd0744640be73": "{count, plural, one {{count} Thread konnte nicht importiert werden.} other {{count} Threads konnten nicht importiert werden.}}", - "ce247a620407cec4": "{count, plural, one {{count} Thread importiert. Ein Teil des Thread-Verlaufs konnte nicht importiert werden.} other {{count} Threads importiert. Ein Teil des Thread-Verlaufs konnte nicht importiert werden.}}", - "a0fd24f965eb070b": "Thread-Verlauf konnte nicht importiert werden.", "a506c135c2183ac3": "{count, plural, one {{count} Ordner} other {{count} Ordner}}", "efc48b9736a534bc": "jetzt", "edf393ff951b533a": "Willkommen bei T3 Code", diff --git a/apps/web/src/i18n/translations/en.json b/apps/web/src/i18n/translations/en.json index 599944358b5bb..767b9af3ffa10 100644 --- a/apps/web/src/i18n/translations/en.json +++ b/apps/web/src/i18n/translations/en.json @@ -2851,6 +2851,12 @@ "5e4a0e56a0788d86": "Recorded content after", "6d5a8b471a561b9d": "File Explorer", "83a174f9e78fe2f1": "Files", + "ce247a620407cec4": "{count, plural, one {Imported {count} thread. Some thread history could not be imported.} other {Imported {count} threads. Some thread history could not be imported.}}", + "a0fd24f965eb070b": "Could not import thread history.", + "b79e42281b0acc9e": "{count, plural, one {Imported {count} thread.} other {Imported {count} threads.}}", + "686dd0744640be73": "{count, plural, one {{count} thread could not be imported.} other {{count} threads could not be imported.}}", + "a58e4704fffba164": "{count, plural, one {{count} thread was not imported yet.} other {{count} threads were not imported yet.}}", + "8b8a18b159e8e1de": "To import them, open the Welcome page again from Settings → About and select their projects under Review all.", "9c867852bab1ce60": "Clipboard API is unavailable while copying error-report.", "a270f51c3f95de49": "Failed to copy error-report to the clipboard.", "09675b4ac9f858dc": "An unexpected router error occurred.", @@ -5940,10 +5946,6 @@ "728b7fa1184ea9c8": "Could not open the setup terminal.", "8769d29d8434e535": "Preparing command...", "f3889aa139ecefa7": "Install {agent}", - "b79e42281b0acc9e": "{count, plural, one {Imported {count} thread.} other {Imported {count} threads.}}", - "686dd0744640be73": "{count, plural, one {{count} thread could not be imported.} other {{count} threads could not be imported.}}", - "ce247a620407cec4": "{count, plural, one {Imported {count} thread. Some thread history could not be imported.} other {Imported {count} threads. Some thread history could not be imported.}}", - "a0fd24f965eb070b": "Could not import thread history.", "a506c135c2183ac3": "{count, plural, one {{count} folder} other {{count} folders}}", "efc48b9736a534bc": "now", "edf393ff951b533a": "Welcome to T3 Code", diff --git a/apps/web/src/i18n/translations/es.json b/apps/web/src/i18n/translations/es.json index 956f4e17a9617..ed4c3d04c34e9 100644 --- a/apps/web/src/i18n/translations/es.json +++ b/apps/web/src/i18n/translations/es.json @@ -2851,6 +2851,12 @@ "5e4a0e56a0788d86": "Contenido registrado después", "6d5a8b471a561b9d": "Explorador de archivos", "83a174f9e78fe2f1": "Archivos", + "ce247a620407cec4": "{count, plural, one {Se importó {count} hilo. Parte del historial de hilos no se pudo importar.} other {Se importaron {count} hilos. Parte del historial de hilos no se pudo importar.}}", + "a0fd24f965eb070b": "No se pudo importar el historial de hilos.", + "b79e42281b0acc9e": "{count, plural, one {Se importó {count} hilo.} other {Se importaron {count} hilos.}}", + "686dd0744640be73": "{count, plural, one {No se pudo importar {count} hilo.} other {No se pudieron importar {count} hilos.}}", + "a58e4704fffba164": "{count, plural, one {Todavía no se importó {count} hilo.} other {Todavía no se importaron {count} hilos.}}", + "8b8a18b159e8e1de": "Para importarlos, vuelve a abrir la página de bienvenida desde Ajustes → Acerca de y selecciona sus proyectos en Revisar.", "9c867852bab1ce60": "La API del portapapeles no está disponible al copiar el informe de error.", "a270f51c3f95de49": "No se pudo copiar el informe de error al portapapeles.", "09675b4ac9f858dc": "Se produjo un error inesperado en el enrutador.", @@ -5938,10 +5944,6 @@ "728b7fa1184ea9c8": "No se pudo abrir la terminal de configuración.", "8769d29d8434e535": "Preparando el comando...", "f3889aa139ecefa7": "Instalar {agent}", - "b79e42281b0acc9e": "{count, plural, one {Se importó {count} hilo.} other {Se importaron {count} hilos.}}", - "686dd0744640be73": "{count, plural, one {No se pudo importar {count} hilo.} other {No se pudieron importar {count} hilos.}}", - "ce247a620407cec4": "{count, plural, one {Se importó {count} hilo. Parte del historial de hilos no se pudo importar.} other {Se importaron {count} hilos. Parte del historial de hilos no se pudo importar.}}", - "a0fd24f965eb070b": "No se pudo importar el historial de hilos.", "a506c135c2183ac3": "{count, plural, one {{count} carpeta} other {{count} carpetas}}", "efc48b9736a534bc": "ahora", "edf393ff951b533a": "Te damos la bienvenida a T3 Code", diff --git a/apps/web/src/i18n/translations/fr.json b/apps/web/src/i18n/translations/fr.json index 1c982cc6d6f58..1fdc193ff1d5a 100644 --- a/apps/web/src/i18n/translations/fr.json +++ b/apps/web/src/i18n/translations/fr.json @@ -2851,6 +2851,12 @@ "5e4a0e56a0788d86": "Contenu enregistré après", "6d5a8b471a561b9d": "Explorateur de fichiers", "83a174f9e78fe2f1": "Fichiers", + "ce247a620407cec4": "{count, plural, one {{count} fil importé. Une partie de l’historique n’a pas pu être importée.} other {{count} fils importés. Une partie de l’historique n’a pas pu être importée.}}", + "a0fd24f965eb070b": "Impossible d’importer l’historique des fils.", + "b79e42281b0acc9e": "{count, plural, one {{count} fil importé.} other {{count} fils importés.}}", + "686dd0744640be73": "{count, plural, one {{count} fil n’a pas pu être importé.} other {{count} fils n’ont pas pu être importés.}}", + "a58e4704fffba164": "{count, plural, one {{count} fil n’a pas encore été importé.} other {{count} fils n’ont pas encore été importés.}}", + "8b8a18b159e8e1de": "Pour les importer, rouvrez la page d’accueil depuis Paramètres → À propos et sélectionnez leurs projets sous Passer en revue.", "9c867852bab1ce60": "L’API Presse-papiers n’est pas disponible pour copier le rapport d’erreur.", "a270f51c3f95de49": "Impossible de copier le rapport d’erreur dans le presse-papiers.", "09675b4ac9f858dc": "Une erreur de routage inattendue s’est produite.", @@ -5939,10 +5945,6 @@ "728b7fa1184ea9c8": "Impossible d’ouvrir le terminal de configuration.", "8769d29d8434e535": "Préparation de la commande...", "f3889aa139ecefa7": "Installer {agent}", - "b79e42281b0acc9e": "{count, plural, one {{count} fil importé.} other {{count} fils importés.}}", - "686dd0744640be73": "{count, plural, one {{count} fil n’a pas pu être importé.} other {{count} fils n’ont pas pu être importés.}}", - "ce247a620407cec4": "{count, plural, one {{count} fil importé. Une partie de l’historique n’a pas pu être importée.} other {{count} fils importés. Une partie de l’historique n’a pas pu être importée.}}", - "a0fd24f965eb070b": "Impossible d’importer l’historique des fils.", "a506c135c2183ac3": "{count, plural, one {{count} dossier} other {{count} dossiers}}", "efc48b9736a534bc": "maintenant", "edf393ff951b533a": "Bienvenue dans T3 Code", diff --git a/apps/web/src/i18n/translations/ja.json b/apps/web/src/i18n/translations/ja.json index 879531a396d2a..aae0685f8d299 100644 --- a/apps/web/src/i18n/translations/ja.json +++ b/apps/web/src/i18n/translations/ja.json @@ -2849,6 +2849,12 @@ "5e4a0e56a0788d86": "記録された変更後の内容", "6d5a8b471a561b9d": "エクスプローラー", "83a174f9e78fe2f1": "ファイル", + "ce247a620407cec4": "{count, plural, other {{count} 件のスレッドをインポートしました。一部のスレッドの履歴はインポートできませんでした。}}", + "a0fd24f965eb070b": "スレッドの履歴をインポートできませんでした。", + "b79e42281b0acc9e": "{count, plural, other {{count} 件のスレッドをインポートしました。}}", + "686dd0744640be73": "{count, plural, other {{count} 件のスレッドをインポートできませんでした。}}", + "a58e4704fffba164": "{count, plural, other {{count} 件のスレッドはまだインポートされていません。}}", + "8b8a18b159e8e1de": "インポートするには、設定 → 情報 からようこそページをもう一度開き、「すべてをレビュー」で対象のプロジェクトを選択してください。", "9c867852bab1ce60": "エラーレポートをコピーする際にクリップボード API を利用できませんでした。", "a270f51c3f95de49": "エラーレポートをクリップボードにコピーできませんでした。", "09675b4ac9f858dc": "予期しないルーターエラーが発生しました。", @@ -5920,10 +5926,6 @@ "728b7fa1184ea9c8": "セットアップ用のターミナルを開けませんでした。", "8769d29d8434e535": "コマンドを準備しています...", "f3889aa139ecefa7": "{agent} をインストール", - "b79e42281b0acc9e": "{count, plural, other {{count} 件のスレッドをインポートしました。}}", - "686dd0744640be73": "{count, plural, other {{count} 件のスレッドをインポートできませんでした。}}", - "ce247a620407cec4": "{count, plural, other {{count} 件のスレッドをインポートしました。一部のスレッドの履歴はインポートできませんでした。}}", - "a0fd24f965eb070b": "スレッドの履歴をインポートできませんでした。", "a506c135c2183ac3": "{count, plural, other {{count} 個のフォルダー}}", "efc48b9736a534bc": "たった今", "edf393ff951b533a": "T3 Code へようこそ", diff --git a/apps/web/src/i18n/translations/ko.json b/apps/web/src/i18n/translations/ko.json index fae8ce2ec6fc4..f0e1dfc9d80c5 100644 --- a/apps/web/src/i18n/translations/ko.json +++ b/apps/web/src/i18n/translations/ko.json @@ -2850,6 +2850,12 @@ "5e4a0e56a0788d86": "변경 후 기록된 내용", "6d5a8b471a561b9d": "파일 탐색기", "83a174f9e78fe2f1": "파일", + "ce247a620407cec4": "{count, plural, other {스레드 {count}개를 가져왔습니다. 일부 스레드 기록은 가져올 수 없었습니다.}}", + "a0fd24f965eb070b": "스레드 기록을 가져올 수 없습니다.", + "b79e42281b0acc9e": "{count, plural, other {스레드 {count}개를 가져왔습니다.}}", + "686dd0744640be73": "{count, plural, other {스레드 {count}개를 가져올 수 없습니다.}}", + "a58e4704fffba164": "{count, plural, other {스레드 {count}개를 아직 가져오지 않았습니다.}}", + "8b8a18b159e8e1de": "가져오려면 설정 → 정보에서 시작 페이지를 다시 열고 모두 검토에서 해당 프로젝트를 선택하세요.", "9c867852bab1ce60": "오류 보고서를 복사하는 중 클립보드 API를 사용할 수 없습니다.", "a270f51c3f95de49": "오류 보고서를 클립보드에 복사하지 못했습니다.", "09675b4ac9f858dc": "예기치 않은 라우터 오류가 발생했습니다.", @@ -5918,10 +5924,6 @@ "728b7fa1184ea9c8": "설정 터미널을 열 수 없습니다.", "8769d29d8434e535": "명령 준비 중...", "f3889aa139ecefa7": "{agent} 설치", - "b79e42281b0acc9e": "{count, plural, other {스레드 {count}개를 가져왔습니다.}}", - "686dd0744640be73": "{count, plural, other {스레드 {count}개를 가져올 수 없습니다.}}", - "ce247a620407cec4": "{count, plural, other {스레드 {count}개를 가져왔습니다. 일부 스레드 기록은 가져올 수 없었습니다.}}", - "a0fd24f965eb070b": "스레드 기록을 가져올 수 없습니다.", "a506c135c2183ac3": "{count, plural, other {폴더 {count}개}}", "efc48b9736a534bc": "지금", "edf393ff951b533a": "T3 Code에 오신 것을 환영합니다", diff --git a/apps/web/src/i18n/translations/pt-BR.json b/apps/web/src/i18n/translations/pt-BR.json index 7010bef288b16..c8ee4ad1d0234 100644 --- a/apps/web/src/i18n/translations/pt-BR.json +++ b/apps/web/src/i18n/translations/pt-BR.json @@ -2851,6 +2851,12 @@ "5e4a0e56a0788d86": "Conteúdo gravado depois", "6d5a8b471a561b9d": "Explorador de Arquivos", "83a174f9e78fe2f1": "Arquivos", + "ce247a620407cec4": "{count, plural, one {{count} thread importada. Parte do histórico não pôde ser importada.} other {{count} threads importadas. Parte do histórico não pôde ser importada.}}", + "a0fd24f965eb070b": "Não foi possível importar o histórico de threads.", + "b79e42281b0acc9e": "{count, plural, one {{count} thread importada.} other {{count} threads importadas.}}", + "686dd0744640be73": "{count, plural, one {Não foi possível importar {count} thread.} other {Não foi possível importar {count} threads.}}", + "a58e4704fffba164": "{count, plural, one {{count} thread ainda não foi importada.} other {{count} threads ainda não foram importadas.}}", + "8b8a18b159e8e1de": "Para importá-las, abra a Página de boas-vindas de novo em Configurações → Sobre e selecione os projetos delas em Revisar todos.", "9c867852bab1ce60": "A API da área de transferência não está disponível ao copiar o relatório de erro.", "a270f51c3f95de49": "Falha ao copiar o relatório de erro para a área de transferência.", "09675b4ac9f858dc": "Ocorreu um erro inesperado no roteador.", @@ -5938,10 +5944,6 @@ "728b7fa1184ea9c8": "Não foi possível abrir o terminal de configuração.", "8769d29d8434e535": "Preparando o comando...", "f3889aa139ecefa7": "Instalar {agent}", - "b79e42281b0acc9e": "{count, plural, one {{count} thread importada.} other {{count} threads importadas.}}", - "686dd0744640be73": "{count, plural, one {Não foi possível importar {count} thread.} other {Não foi possível importar {count} threads.}}", - "ce247a620407cec4": "{count, plural, one {{count} thread importada. Parte do histórico não pôde ser importada.} other {{count} threads importadas. Parte do histórico não pôde ser importada.}}", - "a0fd24f965eb070b": "Não foi possível importar o histórico de threads.", "a506c135c2183ac3": "{count, plural, one {{count} pasta} other {{count} pastas}}", "efc48b9736a534bc": "agora", "edf393ff951b533a": "Boas-vindas ao T3 Code", diff --git a/apps/web/src/i18n/translations/ru.json b/apps/web/src/i18n/translations/ru.json index 0766d953dd02d..4dea3c9819565 100644 --- a/apps/web/src/i18n/translations/ru.json +++ b/apps/web/src/i18n/translations/ru.json @@ -2851,6 +2851,12 @@ "5e4a0e56a0788d86": "Записанное содержимое после", "6d5a8b471a561b9d": "Проводник", "83a174f9e78fe2f1": "Файлы", + "ce247a620407cec4": "{count, plural, one {Импортирован {count} тред. Часть истории тредов импортировать не удалось.} few {Импортировано {count} треда. Часть истории тредов импортировать не удалось.} many {Импортировано {count} тредов. Часть истории тредов импортировать не удалось.} other {Импортировано {count} треда. Часть истории тредов импортировать не удалось.}}", + "a0fd24f965eb070b": "Не удалось импортировать историю тредов.", + "b79e42281b0acc9e": "{count, plural, one {Импортирован {count} тред.} few {Импортировано {count} треда.} many {Импортировано {count} тредов.} other {Импортировано {count} треда.}}", + "686dd0744640be73": "{count, plural, one {Не удалось импортировать {count} тред.} few {Не удалось импортировать {count} треда.} many {Не удалось импортировать {count} тредов.} other {Не удалось импортировать {count} треда.}}", + "a58e4704fffba164": "{count, plural, one {{count} тред ещё не импортирован.} few {{count} треда ещё не импортированы.} many {{count} тредов ещё не импортированы.} other {{count} треда ещё не импортированы.}}", + "8b8a18b159e8e1de": "Чтобы импортировать их, снова откройте страницу приветствия в Настройки → О приложении и выберите их проекты в разделе «Просмотреть все».", "9c867852bab1ce60": "API буфера обмена недоступен при копировании отчёта об ошибке.", "a270f51c3f95de49": "Не удалось скопировать отчёт об ошибке в буфер обмена.", "09675b4ac9f858dc": "Непредвиденная ошибка маршрутизатора.", @@ -5938,10 +5944,6 @@ "728b7fa1184ea9c8": "Не удалось открыть терминал настройки.", "8769d29d8434e535": "Подготовка команды...", "f3889aa139ecefa7": "Установить {agent}", - "b79e42281b0acc9e": "{count, plural, one {Импортирован {count} тред.} few {Импортировано {count} треда.} many {Импортировано {count} тредов.} other {Импортировано {count} треда.}}", - "686dd0744640be73": "{count, plural, one {Не удалось импортировать {count} тред.} few {Не удалось импортировать {count} треда.} many {Не удалось импортировать {count} тредов.} other {Не удалось импортировать {count} треда.}}", - "ce247a620407cec4": "{count, plural, one {Импортирован {count} тред. Часть истории тредов импортировать не удалось.} few {Импортировано {count} треда. Часть истории тредов импортировать не удалось.} many {Импортировано {count} тредов. Часть истории тредов импортировать не удалось.} other {Импортировано {count} треда. Часть истории тредов импортировать не удалось.}}", - "a0fd24f965eb070b": "Не удалось импортировать историю тредов.", "a506c135c2183ac3": "{count, plural, one {{count} папка} few {{count} папки} many {{count} папок} other {{count} папки}}", "efc48b9736a534bc": "сейчас", "edf393ff951b533a": "Добро пожаловать в T3 Code", diff --git a/apps/web/src/i18n/translations/sv.json b/apps/web/src/i18n/translations/sv.json index 5e6d1607edf31..3620975f75d25 100644 --- a/apps/web/src/i18n/translations/sv.json +++ b/apps/web/src/i18n/translations/sv.json @@ -2851,6 +2851,12 @@ "5e4a0e56a0788d86": "Inspelat innehåll efter", "6d5a8b471a561b9d": "Utforskaren", "83a174f9e78fe2f1": "Filer", + "ce247a620407cec4": "{count, plural, one {Importerade {count} tråd. En del trådhistorik kunde inte importeras.} other {Importerade {count} trådar. En del trådhistorik kunde inte importeras.}}", + "a0fd24f965eb070b": "Kunde inte importera trådhistorik.", + "b79e42281b0acc9e": "{count, plural, one {Importerade {count} tråd.} other {Importerade {count} trådar.}}", + "686dd0744640be73": "{count, plural, one {{count} tråd kunde inte importeras.} other {{count} trådar kunde inte importeras.}}", + "a58e4704fffba164": "{count, plural, one {{count} tråd har inte importerats än.} other {{count} trådar har inte importerats än.}}", + "8b8a18b159e8e1de": "Öppna välkomstsidan igen från Inställningar → Om och välj deras projekt under Granska alla för att importera dem.", "9c867852bab1ce60": "Urklipps-API:t är inte tillgängligt vid kopiering av felrapporten.", "a270f51c3f95de49": "Kunde inte kopiera felrapporten till urklipp.", "09675b4ac9f858dc": "Ett oväntat routerfel uppstod.", @@ -5939,10 +5945,6 @@ "728b7fa1184ea9c8": "Kunde inte öppna konfigurationsterminalen.", "8769d29d8434e535": "Förbereder kommando...", "f3889aa139ecefa7": "Installera {agent}", - "b79e42281b0acc9e": "{count, plural, one {Importerade {count} tråd.} other {Importerade {count} trådar.}}", - "686dd0744640be73": "{count, plural, one {{count} tråd kunde inte importeras.} other {{count} trådar kunde inte importeras.}}", - "ce247a620407cec4": "{count, plural, one {Importerade {count} tråd. En del trådhistorik kunde inte importeras.} other {Importerade {count} trådar. En del trådhistorik kunde inte importeras.}}", - "a0fd24f965eb070b": "Kunde inte importera trådhistorik.", "a506c135c2183ac3": "{count, plural, one {{count} mapp} other {{count} mappar}}", "efc48b9736a534bc": "nu", "edf393ff951b533a": "Välkommen till T3 Code", diff --git a/apps/web/src/i18n/translations/zh.json b/apps/web/src/i18n/translations/zh.json index c86b9e6c55e41..ac5aad36e795b 100644 --- a/apps/web/src/i18n/translations/zh.json +++ b/apps/web/src/i18n/translations/zh.json @@ -2855,6 +2855,12 @@ "5e4a0e56a0788d86": "记录的内容(之后)", "6d5a8b471a561b9d": "文件资源管理器", "83a174f9e78fe2f1": "文件", + "ce247a620407cec4": "{count, plural, other {已导入 {count} 个会话。部分会话历史无法导入。}}", + "a0fd24f965eb070b": "无法导入会话历史。", + "b79e42281b0acc9e": "{count, plural, other {已导入 {count} 个会话。}}", + "686dd0744640be73": "{count, plural, other {{count} 个会话无法导入。}}", + "a58e4704fffba164": "{count, plural, other {{count} 个会话尚未导入。}}", + "8b8a18b159e8e1de": "要导入它们,请从“设置 → 关于”再次打开欢迎页,并在“审查全部”中选择它们所属的项目。", "9c867852bab1ce60": "复制错误报告时剪贴板 API 不可用。", "a270f51c3f95de49": "无法将错误报告复制到剪贴板。", "09675b4ac9f858dc": "发生意外的路由错误。", @@ -5945,10 +5951,6 @@ "728b7fa1184ea9c8": "无法打开设置终端。", "8769d29d8434e535": "正在准备命令…", "f3889aa139ecefa7": "安装 {agent}", - "b79e42281b0acc9e": "{count, plural, other {已导入 {count} 个会话。}}", - "686dd0744640be73": "{count, plural, other {{count} 个会话无法导入。}}", - "ce247a620407cec4": "{count, plural, other {已导入 {count} 个会话。部分会话历史无法导入。}}", - "a0fd24f965eb070b": "无法导入会话历史。", "a506c135c2183ac3": "{count, plural, other {{count} 个文件夹}}", "efc48b9736a534bc": "刚刚", "edf393ff951b533a": "欢迎使用 T3 Code", diff --git a/apps/web/src/onboarding/projectImport.logic.test.ts b/apps/web/src/onboarding/projectImport.logic.test.ts index 10cb0d731ee75..a28566d30d70d 100644 --- a/apps/web/src/onboarding/projectImport.logic.test.ts +++ b/apps/web/src/onboarding/projectImport.logic.test.ts @@ -6,6 +6,7 @@ import { isNewOnboardingProject, partitionOnboardingProjects, onboardingProjectKey, + projectImportWarning, resolveOnboardingLandingProject, resolveOnboardingProjectId, } from "./projectImport.logic"; @@ -232,6 +233,36 @@ describe("resolveOnboardingLandingProject", () => { }); }); +describe("projectImportWarning", () => { + const resume = + "To import them, open the Welcome page again from Settings → About and select their projects under Review all."; + + it.each([ + { + totals: { imported: 100, failed: 0, deferred: 153 }, + warning: `Imported 100 threads. 153 threads were not imported yet. ${resume}`, + }, + { + totals: { imported: 100, failed: 3, deferred: 1 }, + warning: `Imported 100 threads. 3 threads could not be imported. 1 thread was not imported yet. ${resume}`, + }, + { + totals: { imported: 0, failed: 2, deferred: 0 }, + warning: "2 threads could not be imported.", + }, + { + totals: { imported: 5, failed: 0, deferred: 0 }, + warning: "Imported 5 threads. Some thread history could not be imported.", + }, + { + totals: { imported: 0, failed: 0, deferred: 0 }, + warning: "Could not import thread history.", + }, + ])("separates deferred threads from failures: $warning", ({ totals, warning }) => { + expect(projectImportWarning(totals)).toBe(warning); + }); +}); + describe("projects on multiple computers", () => { it("keeps identical paths independent when selecting a landing project after partial imports", () => { const first = onboardingProjectKey(EnvironmentId.make("first"), "/code/app"); diff --git a/apps/web/src/onboarding/projectImport.logic.ts b/apps/web/src/onboarding/projectImport.logic.ts index 1be9c7b824b2a..a2191d44d4348 100644 --- a/apps/web/src/onboarding/projectImport.logic.ts +++ b/apps/web/src/onboarding/projectImport.logic.ts @@ -3,6 +3,9 @@ import { normalizeProjectPathForComparison, } from "@t3tools/client-runtime/state/projects"; import type { AgentSessionProjectCandidate, EnvironmentId, ProjectId } from "@t3tools/contracts"; +import { msg } from "gt-react"; + +import { m, type MessageResolver } from "../i18n/messages"; const RECENT_PROJECT_WINDOW_MS = 30 * 24 * 60 * 60 * 1000; const DEFAULT_SELECTION_MIN_THREADS = 3; @@ -146,6 +149,63 @@ export function resolveOnboardingLandingProject( return undefined; } +/** + * The summary for an import that left threads behind. Deferred threads hit the per-attempt + * budget and import on a later attempt, so they are not reported as failures. + */ +export function projectImportWarning( + totals: { readonly imported: number; readonly failed: number; readonly deferred: number }, + resolve: MessageResolver = m, +): string { + const { imported, failed, deferred } = totals; + if (failed === 0 && deferred === 0) { + return imported > 0 + ? resolve( + msg( + "{count, plural, one {Imported {count} thread. Some thread history could not be imported.} other {Imported {count} threads. Some thread history could not be imported.}}", + { count: imported }, + ), + ) + : resolve(msg("Could not import thread history.")); + } + const sentences: Array = []; + if (imported > 0) { + sentences.push( + resolve( + msg("{count, plural, one {Imported {count} thread.} other {Imported {count} threads.}}", { + count: imported, + }), + ), + ); + } + if (failed > 0) { + sentences.push( + resolve( + msg( + "{count, plural, one {{count} thread could not be imported.} other {{count} threads could not be imported.}}", + { count: failed }, + ), + ), + ); + } + if (deferred > 0) { + sentences.push( + resolve( + msg( + "{count, plural, one {{count} thread was not imported yet.} other {{count} threads were not imported yet.}}", + { count: deferred }, + ), + ), + resolve( + msg( + "To import them, open the Welcome page again from Settings → About and select their projects under Review all.", + ), + ), + ); + } + return sentences.join(" "); +} + export function splitOnboardingProjectPath(path: string): { readonly name: string; readonly parent: string; diff --git a/docs/user/welcome-page.md b/docs/user/welcome-page.md index a914349694156..0cb044c1d179d 100644 --- a/docs/user/welcome-page.md +++ b/docs/user/welcome-page.md @@ -104,8 +104,10 @@ malformed records and conversations with no messages, such as a session opened in an editor but never used. It skips unreadable or unparseable conversations. Each import attempt reads up to 100 conversations and 4 GiB per project. -Conversations with no messages count toward the 4 GiB but not the 100. To -continue a large batch, open the Welcome page again and pick the project in +Conversations with no messages count toward the 4 GiB but not the 100. The +summary counts the conversations past that limit as not imported yet, separately +from conversations that could not be imported. To continue a large batch, open +the Welcome page again from **Settings → About** and pick the project in **Review all**. Completed conversations are not imported again. You can continue without the remaining history. diff --git a/packages/contracts/src/agentSessions.ts b/packages/contracts/src/agentSessions.ts index 93e0e36e4fbd4..cb0350ccd8e65 100644 --- a/packages/contracts/src/agentSessions.ts +++ b/packages/contracts/src/agentSessions.ts @@ -75,6 +75,8 @@ export class AgentSessionImportProjectChangedError extends Schema.TaggedError `00000000-0000-4000-8000-${String(index).padStart(12, "0")}`; + +const rollout = (cwd: string, index: number) => + [ + { type: "session_meta", payload: { id: sessionId(index), cwd } }, + { type: "event_msg", payload: { type: "user_message", message: `Request ${index}` } }, + { + type: "response_item", + payload: { + type: "message", + role: "assistant", + content: [{ type: "output_text", text: "Done" }], + }, + }, + ] + .map((record) => `${JSON.stringify(record)}\n`) + .join(""); + +const JsonObject = Schema.fromJsonString(Schema.Record(Schema.String, Schema.Unknown)); +const decodeSettings = Schema.decodeUnknownEffect(JsonObject); +const encodeSettings = Schema.encodeEffect(JsonObject); +const decodeProviderInstances = Schema.decodeUnknownEffect( + Schema.Record(Schema.String, Schema.Unknown), +); + +/** + * A repository and a Codex home holding its sessions, outside the T3 home, which the scanner + * skips. The scenario app keeps Codex off; this turns it on with that home. + */ +const seed = Effect.gen(function* () { + const fs = yield* FileSystem.FileSystem; + const path = yield* Path.Path; + const root = yield* fs.makeTempDirectory({ prefix: "t3-import-deferred-" }); + const workspace = path.join(root, "demo-app"); + const codexHome = path.join(root, "codex"); + const sessions = path.join(codexHome, "sessions", "2026", "01", "01"); + yield* fs.makeDirectory(workspace, { recursive: true }); + yield* fs.makeDirectory(sessions, { recursive: true }); + for (let index = 0; index < SESSIONS; index++) { + yield* fs.writeFileString( + path.join(sessions, `rollout-2026-01-01T00-00-00-${sessionId(index)}.jsonl`), + rollout(workspace, index), + ); + } + + const settingsPath = path.join(T3_HOME, "userdata", "settings.json"); + const settings = yield* decodeSettings(yield* fs.readFileString(settingsPath)); + const providerInstances = yield* decodeProviderInstances(settings.providerInstances); + yield* fs.writeFileString( + settingsPath, + yield* encodeSettings({ + ...settings, + providerInstances: { + ...providerInstances, + codex: { + driver: "codex", + enabled: true, + config: { binaryPath: path.join(T3_HOME, "bin", "no-model"), homePath: codexHome }, + }, + }, + }), + ); + return { root, workspace }; +}); + +test( + "Importing more conversations than one attempt reads reports the rest as not imported yet", + WEB, + async ({ t3, app, screen }) => { + const { root, workspace } = await runPromise(seed); + try { + await runPromise( + run("git", ["init", "--quiet", "--initial-branch=main"], { cwd: workspace }), + ); + + // The server reloads settings.json while the page signs in; it scans once it opens. + await t3.open(); + await screen.getByRole("button", "Import 1 project and start").tap(); + const summary = screen.getByText("Imported 100 threads.", { exact: false }); + await summary.waitFor({ timeout: 60_000 }); + await app.screenshot("import-summary"); + + await expect(summary).toHaveText( + "Imported 100 threads. 1 thread was not imported yet. To import them, open the Welcome page again from Settings → About and select their projects under Review all.", + ); + } finally { + await runPromise( + Effect.flatMap(FileSystem.FileSystem, (fs) => fs.remove(root, { recursive: true })), + ); + } + }, +); From 27ff3da428ec4eb598ffc003afc19decebfc6dc2 Mon Sep 17 00:00:00 2001 From: Matheus Marques Botelho Date: Wed, 18 Nov 2026 02:07:18 -0300 Subject: [PATCH 2/3] fix(web): import summary still reports a failed project next to deferred threads --- .../src/components/onboarding/WelcomePage.tsx | 12 +++++++++--- apps/web/src/i18n/translations/de.json | 1 + apps/web/src/i18n/translations/en.json | 1 + apps/web/src/i18n/translations/es.json | 1 + apps/web/src/i18n/translations/fr.json | 1 + apps/web/src/i18n/translations/ja.json | 1 + apps/web/src/i18n/translations/ko.json | 1 + apps/web/src/i18n/translations/pt-BR.json | 1 + apps/web/src/i18n/translations/ru.json | 1 + apps/web/src/i18n/translations/sv.json | 1 + apps/web/src/i18n/translations/zh.json | 1 + .../onboarding/projectImport.logic.test.ts | 14 +++++++++----- .../web/src/onboarding/projectImport.logic.ts | 11 +++++++++-- ...reports-deferred-threads-separately.e2e.ts | 19 ++++++++++++------- 14 files changed, 49 insertions(+), 17 deletions(-) diff --git a/apps/web/src/components/onboarding/WelcomePage.tsx b/apps/web/src/components/onboarding/WelcomePage.tsx index b5f7c4e7079cb..ecc62b88b4f47 100644 --- a/apps/web/src/components/onboarding/WelcomePage.tsx +++ b/apps/web/src/components/onboarding/WelcomePage.tsx @@ -1621,6 +1621,7 @@ function useProjectImport({ : 0; let skippedThreadCount = 0; let deferredThreadCount = 0; + let requestFailed = false; const refreshEnvironments = new Set(); // Resolves false when the run stopped early: a newer run, an unmount, or lost access. const importEach = async () => { @@ -1657,6 +1658,7 @@ function useProjectImport({ }); if (importGeneration !== importGenerationRef.current) return false; if (result._tag !== "Success") { + requestFailed = true; if (!isAtomCommandInterrupted(result)) { projectAttempts.delete(candidate.key); refreshEnvironments.add(environmentId); @@ -1691,9 +1693,12 @@ function useProjectImport({ importedProjectsCount += 1; importedProjects.set(candidate.key, scopeProjectRef(environmentId, projectId)); } - } else if (!isAtomCommandInterrupted(threadImportResult)) { - projectAttempts.delete(candidate.key); - refreshEnvironments.add(environmentId); + } else { + requestFailed = true; + if (!isAtomCommandInterrupted(threadImportResult)) { + projectAttempts.delete(candidate.key); + refreshEnvironments.add(environmentId); + } } } return true; @@ -1713,6 +1718,7 @@ function useProjectImport({ imported: importedThreadCount, failed: skippedThreadCount - deferredThreadCount, deferred: deferredThreadCount, + requestFailed, }); } finishAfterImport(); diff --git a/apps/web/src/i18n/translations/de.json b/apps/web/src/i18n/translations/de.json index 8cf7133a841a8..734c4e3aa8e90 100644 --- a/apps/web/src/i18n/translations/de.json +++ b/apps/web/src/i18n/translations/de.json @@ -2856,6 +2856,7 @@ "a0fd24f965eb070b": "Thread-Verlauf konnte nicht importiert werden.", "b79e42281b0acc9e": "{count, plural, one {{count} Thread importiert.} other {{count} Threads importiert.}}", "686dd0744640be73": "{count, plural, one {{count} Thread konnte nicht importiert werden.} other {{count} Threads konnten nicht importiert werden.}}", + "ed2f3077617c32f8": "Ein Teil des Thread-Verlaufs konnte nicht importiert werden.", "a58e4704fffba164": "{count, plural, one {{count} Thread wurde noch nicht importiert.} other {{count} Threads wurden noch nicht importiert.}}", "8b8a18b159e8e1de": "Um sie zu importieren, öffne die Willkommensseite erneut über Einstellungen → Info und wähle ihre Projekte unter „Alle prüfen“ aus.", "9c867852bab1ce60": "Die Zwischenablage-API ist beim Kopieren des Fehlerberichts nicht verfügbar.", diff --git a/apps/web/src/i18n/translations/en.json b/apps/web/src/i18n/translations/en.json index 767b9af3ffa10..a5eb77f9d16a8 100644 --- a/apps/web/src/i18n/translations/en.json +++ b/apps/web/src/i18n/translations/en.json @@ -2855,6 +2855,7 @@ "a0fd24f965eb070b": "Could not import thread history.", "b79e42281b0acc9e": "{count, plural, one {Imported {count} thread.} other {Imported {count} threads.}}", "686dd0744640be73": "{count, plural, one {{count} thread could not be imported.} other {{count} threads could not be imported.}}", + "ed2f3077617c32f8": "Some thread history could not be imported.", "a58e4704fffba164": "{count, plural, one {{count} thread was not imported yet.} other {{count} threads were not imported yet.}}", "8b8a18b159e8e1de": "To import them, open the Welcome page again from Settings → About and select their projects under Review all.", "9c867852bab1ce60": "Clipboard API is unavailable while copying error-report.", diff --git a/apps/web/src/i18n/translations/es.json b/apps/web/src/i18n/translations/es.json index ed4c3d04c34e9..d365f9eae7af0 100644 --- a/apps/web/src/i18n/translations/es.json +++ b/apps/web/src/i18n/translations/es.json @@ -2855,6 +2855,7 @@ "a0fd24f965eb070b": "No se pudo importar el historial de hilos.", "b79e42281b0acc9e": "{count, plural, one {Se importó {count} hilo.} other {Se importaron {count} hilos.}}", "686dd0744640be73": "{count, plural, one {No se pudo importar {count} hilo.} other {No se pudieron importar {count} hilos.}}", + "ed2f3077617c32f8": "Parte del historial de hilos no se pudo importar.", "a58e4704fffba164": "{count, plural, one {Todavía no se importó {count} hilo.} other {Todavía no se importaron {count} hilos.}}", "8b8a18b159e8e1de": "Para importarlos, vuelve a abrir la página de bienvenida desde Ajustes → Acerca de y selecciona sus proyectos en Revisar.", "9c867852bab1ce60": "La API del portapapeles no está disponible al copiar el informe de error.", diff --git a/apps/web/src/i18n/translations/fr.json b/apps/web/src/i18n/translations/fr.json index 1fdc193ff1d5a..4b75cb7cf294f 100644 --- a/apps/web/src/i18n/translations/fr.json +++ b/apps/web/src/i18n/translations/fr.json @@ -2855,6 +2855,7 @@ "a0fd24f965eb070b": "Impossible d’importer l’historique des fils.", "b79e42281b0acc9e": "{count, plural, one {{count} fil importé.} other {{count} fils importés.}}", "686dd0744640be73": "{count, plural, one {{count} fil n’a pas pu être importé.} other {{count} fils n’ont pas pu être importés.}}", + "ed2f3077617c32f8": "Une partie de l’historique n’a pas pu être importée.", "a58e4704fffba164": "{count, plural, one {{count} fil n’a pas encore été importé.} other {{count} fils n’ont pas encore été importés.}}", "8b8a18b159e8e1de": "Pour les importer, rouvrez la page d’accueil depuis Paramètres → À propos et sélectionnez leurs projets sous Passer en revue.", "9c867852bab1ce60": "L’API Presse-papiers n’est pas disponible pour copier le rapport d’erreur.", diff --git a/apps/web/src/i18n/translations/ja.json b/apps/web/src/i18n/translations/ja.json index aae0685f8d299..0a6fbbfb7b29e 100644 --- a/apps/web/src/i18n/translations/ja.json +++ b/apps/web/src/i18n/translations/ja.json @@ -2853,6 +2853,7 @@ "a0fd24f965eb070b": "スレッドの履歴をインポートできませんでした。", "b79e42281b0acc9e": "{count, plural, other {{count} 件のスレッドをインポートしました。}}", "686dd0744640be73": "{count, plural, other {{count} 件のスレッドをインポートできませんでした。}}", + "ed2f3077617c32f8": "一部のスレッドの履歴はインポートできませんでした。", "a58e4704fffba164": "{count, plural, other {{count} 件のスレッドはまだインポートされていません。}}", "8b8a18b159e8e1de": "インポートするには、設定 → 情報 からようこそページをもう一度開き、「すべてをレビュー」で対象のプロジェクトを選択してください。", "9c867852bab1ce60": "エラーレポートをコピーする際にクリップボード API を利用できませんでした。", diff --git a/apps/web/src/i18n/translations/ko.json b/apps/web/src/i18n/translations/ko.json index f0e1dfc9d80c5..835c15ef0e655 100644 --- a/apps/web/src/i18n/translations/ko.json +++ b/apps/web/src/i18n/translations/ko.json @@ -2854,6 +2854,7 @@ "a0fd24f965eb070b": "스레드 기록을 가져올 수 없습니다.", "b79e42281b0acc9e": "{count, plural, other {스레드 {count}개를 가져왔습니다.}}", "686dd0744640be73": "{count, plural, other {스레드 {count}개를 가져올 수 없습니다.}}", + "ed2f3077617c32f8": "일부 스레드 기록은 가져올 수 없었습니다.", "a58e4704fffba164": "{count, plural, other {스레드 {count}개를 아직 가져오지 않았습니다.}}", "8b8a18b159e8e1de": "가져오려면 설정 → 정보에서 시작 페이지를 다시 열고 모두 검토에서 해당 프로젝트를 선택하세요.", "9c867852bab1ce60": "오류 보고서를 복사하는 중 클립보드 API를 사용할 수 없습니다.", diff --git a/apps/web/src/i18n/translations/pt-BR.json b/apps/web/src/i18n/translations/pt-BR.json index c8ee4ad1d0234..510e4976e6fba 100644 --- a/apps/web/src/i18n/translations/pt-BR.json +++ b/apps/web/src/i18n/translations/pt-BR.json @@ -2855,6 +2855,7 @@ "a0fd24f965eb070b": "Não foi possível importar o histórico de threads.", "b79e42281b0acc9e": "{count, plural, one {{count} thread importada.} other {{count} threads importadas.}}", "686dd0744640be73": "{count, plural, one {Não foi possível importar {count} thread.} other {Não foi possível importar {count} threads.}}", + "ed2f3077617c32f8": "Parte do histórico não pôde ser importada.", "a58e4704fffba164": "{count, plural, one {{count} thread ainda não foi importada.} other {{count} threads ainda não foram importadas.}}", "8b8a18b159e8e1de": "Para importá-las, abra a Página de boas-vindas de novo em Configurações → Sobre e selecione os projetos delas em Revisar todos.", "9c867852bab1ce60": "A API da área de transferência não está disponível ao copiar o relatório de erro.", diff --git a/apps/web/src/i18n/translations/ru.json b/apps/web/src/i18n/translations/ru.json index 4dea3c9819565..4dc3bb9688293 100644 --- a/apps/web/src/i18n/translations/ru.json +++ b/apps/web/src/i18n/translations/ru.json @@ -2855,6 +2855,7 @@ "a0fd24f965eb070b": "Не удалось импортировать историю тредов.", "b79e42281b0acc9e": "{count, plural, one {Импортирован {count} тред.} few {Импортировано {count} треда.} many {Импортировано {count} тредов.} other {Импортировано {count} треда.}}", "686dd0744640be73": "{count, plural, one {Не удалось импортировать {count} тред.} few {Не удалось импортировать {count} треда.} many {Не удалось импортировать {count} тредов.} other {Не удалось импортировать {count} треда.}}", + "ed2f3077617c32f8": "Часть истории тредов импортировать не удалось.", "a58e4704fffba164": "{count, plural, one {{count} тред ещё не импортирован.} few {{count} треда ещё не импортированы.} many {{count} тредов ещё не импортированы.} other {{count} треда ещё не импортированы.}}", "8b8a18b159e8e1de": "Чтобы импортировать их, снова откройте страницу приветствия в Настройки → О приложении и выберите их проекты в разделе «Просмотреть все».", "9c867852bab1ce60": "API буфера обмена недоступен при копировании отчёта об ошибке.", diff --git a/apps/web/src/i18n/translations/sv.json b/apps/web/src/i18n/translations/sv.json index 3620975f75d25..b28d52d225b99 100644 --- a/apps/web/src/i18n/translations/sv.json +++ b/apps/web/src/i18n/translations/sv.json @@ -2855,6 +2855,7 @@ "a0fd24f965eb070b": "Kunde inte importera trådhistorik.", "b79e42281b0acc9e": "{count, plural, one {Importerade {count} tråd.} other {Importerade {count} trådar.}}", "686dd0744640be73": "{count, plural, one {{count} tråd kunde inte importeras.} other {{count} trådar kunde inte importeras.}}", + "ed2f3077617c32f8": "En del trådhistorik kunde inte importeras.", "a58e4704fffba164": "{count, plural, one {{count} tråd har inte importerats än.} other {{count} trådar har inte importerats än.}}", "8b8a18b159e8e1de": "Öppna välkomstsidan igen från Inställningar → Om och välj deras projekt under Granska alla för att importera dem.", "9c867852bab1ce60": "Urklipps-API:t är inte tillgängligt vid kopiering av felrapporten.", diff --git a/apps/web/src/i18n/translations/zh.json b/apps/web/src/i18n/translations/zh.json index ac5aad36e795b..8decce4e4864a 100644 --- a/apps/web/src/i18n/translations/zh.json +++ b/apps/web/src/i18n/translations/zh.json @@ -2859,6 +2859,7 @@ "a0fd24f965eb070b": "无法导入会话历史。", "b79e42281b0acc9e": "{count, plural, other {已导入 {count} 个会话。}}", "686dd0744640be73": "{count, plural, other {{count} 个会话无法导入。}}", + "ed2f3077617c32f8": "部分会话历史无法导入。", "a58e4704fffba164": "{count, plural, other {{count} 个会话尚未导入。}}", "8b8a18b159e8e1de": "要导入它们,请从“设置 → 关于”再次打开欢迎页,并在“审查全部”中选择它们所属的项目。", "9c867852bab1ce60": "复制错误报告时剪贴板 API 不可用。", diff --git a/apps/web/src/onboarding/projectImport.logic.test.ts b/apps/web/src/onboarding/projectImport.logic.test.ts index a28566d30d70d..d62900bf8575c 100644 --- a/apps/web/src/onboarding/projectImport.logic.test.ts +++ b/apps/web/src/onboarding/projectImport.logic.test.ts @@ -239,23 +239,27 @@ describe("projectImportWarning", () => { it.each([ { - totals: { imported: 100, failed: 0, deferred: 153 }, + totals: { imported: 100, failed: 0, deferred: 153, requestFailed: false }, warning: `Imported 100 threads. 153 threads were not imported yet. ${resume}`, }, { - totals: { imported: 100, failed: 3, deferred: 1 }, + totals: { imported: 100, failed: 3, deferred: 1, requestFailed: false }, warning: `Imported 100 threads. 3 threads could not be imported. 1 thread was not imported yet. ${resume}`, }, { - totals: { imported: 0, failed: 2, deferred: 0 }, + totals: { imported: 100, failed: 0, deferred: 53, requestFailed: true }, + warning: `Imported 100 threads. Some thread history could not be imported. 53 threads were not imported yet. ${resume}`, + }, + { + totals: { imported: 0, failed: 2, deferred: 0, requestFailed: false }, warning: "2 threads could not be imported.", }, { - totals: { imported: 5, failed: 0, deferred: 0 }, + totals: { imported: 5, failed: 0, deferred: 0, requestFailed: true }, warning: "Imported 5 threads. Some thread history could not be imported.", }, { - totals: { imported: 0, failed: 0, deferred: 0 }, + totals: { imported: 0, failed: 0, deferred: 0, requestFailed: true }, warning: "Could not import thread history.", }, ])("separates deferred threads from failures: $warning", ({ totals, warning }) => { diff --git a/apps/web/src/onboarding/projectImport.logic.ts b/apps/web/src/onboarding/projectImport.logic.ts index a2191d44d4348..4c717c521ad6f 100644 --- a/apps/web/src/onboarding/projectImport.logic.ts +++ b/apps/web/src/onboarding/projectImport.logic.ts @@ -154,10 +154,15 @@ export function resolveOnboardingLandingProject( * budget and import on a later attempt, so they are not reported as failures. */ export function projectImportWarning( - totals: { readonly imported: number; readonly failed: number; readonly deferred: number }, + totals: { + readonly imported: number; + readonly failed: number; + readonly deferred: number; + readonly requestFailed: boolean; + }, resolve: MessageResolver = m, ): string { - const { imported, failed, deferred } = totals; + const { imported, failed, deferred, requestFailed } = totals; if (failed === 0 && deferred === 0) { return imported > 0 ? resolve( @@ -187,6 +192,8 @@ export function projectImportWarning( ), ), ); + } else if (requestFailed) { + sentences.push(resolve(msg("Some thread history could not be imported."))); } if (deferred > 0) { sentences.push( diff --git a/scripts/scenarios/import-reports-deferred-threads-separately.e2e.ts b/scripts/scenarios/import-reports-deferred-threads-separately.e2e.ts index a06594df04b64..8f93c0cd7e108 100644 --- a/scripts/scenarios/import-reports-deferred-threads-separately.e2e.ts +++ b/scripts/scenarios/import-reports-deferred-threads-separately.e2e.ts @@ -6,7 +6,7 @@ import * as Schema from "effect/Schema"; import { T3_HOME } from "../e2e.config.ts"; import { run } from "./shell.ts"; -import { runPromise, test, WEB } from "./t3.ts"; +import { makeState, runPromise, test, WEB } from "./t3.ts"; // One more conversation than an import attempt reads. const SESSIONS = 101; @@ -57,7 +57,8 @@ const seed = Effect.gen(function* () { } const settingsPath = path.join(T3_HOME, "userdata", "settings.json"); - const settings = yield* decodeSettings(yield* fs.readFileString(settingsPath)); + const original = yield* fs.readFileString(settingsPath); + const settings = yield* decodeSettings(original); const providerInstances = yield* decodeProviderInstances(settings.providerInstances); yield* fs.writeFileString( settingsPath, @@ -73,14 +74,20 @@ const seed = Effect.gen(function* () { }, }), ); - return { root, workspace }; + // The server is shared by later tests, so they get its settings back without this project. + const restore = Effect.gen(function* () { + yield* makeState(T3_HOME).cli(["project", "remove", workspace, "--force"]).pipe(Effect.ignore); + yield* fs.writeFileString(settingsPath, original); + yield* fs.remove(root, { recursive: true }); + }); + return { workspace, restore }; }); test( "Importing more conversations than one attempt reads reports the rest as not imported yet", WEB, async ({ t3, app, screen }) => { - const { root, workspace } = await runPromise(seed); + const { workspace, restore } = await runPromise(seed); try { await runPromise( run("git", ["init", "--quiet", "--initial-branch=main"], { cwd: workspace }), @@ -97,9 +104,7 @@ test( "Imported 100 threads. 1 thread was not imported yet. To import them, open the Welcome page again from Settings → About and select their projects under Review all.", ); } finally { - await runPromise( - Effect.flatMap(FileSystem.FileSystem, (fs) => fs.remove(root, { recursive: true })), - ); + await runPromise(restore); } }, ); From 962a0d747e4063a9cd70709d21dae5ed73552e6c Mon Sep 17 00:00:00 2001 From: Matheus Marques Botelho Date: Wed, 18 Nov 2026 08:48:01 -0300 Subject: [PATCH 3/3] test(scripts): drop the scenario that repeats the importer regression test --- ...reports-deferred-threads-separately.e2e.ts | 110 ------------------ 1 file changed, 110 deletions(-) delete mode 100644 scripts/scenarios/import-reports-deferred-threads-separately.e2e.ts diff --git a/scripts/scenarios/import-reports-deferred-threads-separately.e2e.ts b/scripts/scenarios/import-reports-deferred-threads-separately.e2e.ts deleted file mode 100644 index 8f93c0cd7e108..0000000000000 --- a/scripts/scenarios/import-reports-deferred-threads-separately.e2e.ts +++ /dev/null @@ -1,110 +0,0 @@ -import { expect } from "e2e"; -import * as Effect from "effect/Effect"; -import * as FileSystem from "effect/FileSystem"; -import * as Path from "effect/Path"; -import * as Schema from "effect/Schema"; - -import { T3_HOME } from "../e2e.config.ts"; -import { run } from "./shell.ts"; -import { makeState, runPromise, test, WEB } from "./t3.ts"; - -// One more conversation than an import attempt reads. -const SESSIONS = 101; - -const sessionId = (index: number) => `00000000-0000-4000-8000-${String(index).padStart(12, "0")}`; - -const rollout = (cwd: string, index: number) => - [ - { type: "session_meta", payload: { id: sessionId(index), cwd } }, - { type: "event_msg", payload: { type: "user_message", message: `Request ${index}` } }, - { - type: "response_item", - payload: { - type: "message", - role: "assistant", - content: [{ type: "output_text", text: "Done" }], - }, - }, - ] - .map((record) => `${JSON.stringify(record)}\n`) - .join(""); - -const JsonObject = Schema.fromJsonString(Schema.Record(Schema.String, Schema.Unknown)); -const decodeSettings = Schema.decodeUnknownEffect(JsonObject); -const encodeSettings = Schema.encodeEffect(JsonObject); -const decodeProviderInstances = Schema.decodeUnknownEffect( - Schema.Record(Schema.String, Schema.Unknown), -); - -/** - * A repository and a Codex home holding its sessions, outside the T3 home, which the scanner - * skips. The scenario app keeps Codex off; this turns it on with that home. - */ -const seed = Effect.gen(function* () { - const fs = yield* FileSystem.FileSystem; - const path = yield* Path.Path; - const root = yield* fs.makeTempDirectory({ prefix: "t3-import-deferred-" }); - const workspace = path.join(root, "demo-app"); - const codexHome = path.join(root, "codex"); - const sessions = path.join(codexHome, "sessions", "2026", "01", "01"); - yield* fs.makeDirectory(workspace, { recursive: true }); - yield* fs.makeDirectory(sessions, { recursive: true }); - for (let index = 0; index < SESSIONS; index++) { - yield* fs.writeFileString( - path.join(sessions, `rollout-2026-01-01T00-00-00-${sessionId(index)}.jsonl`), - rollout(workspace, index), - ); - } - - const settingsPath = path.join(T3_HOME, "userdata", "settings.json"); - const original = yield* fs.readFileString(settingsPath); - const settings = yield* decodeSettings(original); - const providerInstances = yield* decodeProviderInstances(settings.providerInstances); - yield* fs.writeFileString( - settingsPath, - yield* encodeSettings({ - ...settings, - providerInstances: { - ...providerInstances, - codex: { - driver: "codex", - enabled: true, - config: { binaryPath: path.join(T3_HOME, "bin", "no-model"), homePath: codexHome }, - }, - }, - }), - ); - // The server is shared by later tests, so they get its settings back without this project. - const restore = Effect.gen(function* () { - yield* makeState(T3_HOME).cli(["project", "remove", workspace, "--force"]).pipe(Effect.ignore); - yield* fs.writeFileString(settingsPath, original); - yield* fs.remove(root, { recursive: true }); - }); - return { workspace, restore }; -}); - -test( - "Importing more conversations than one attempt reads reports the rest as not imported yet", - WEB, - async ({ t3, app, screen }) => { - const { workspace, restore } = await runPromise(seed); - try { - await runPromise( - run("git", ["init", "--quiet", "--initial-branch=main"], { cwd: workspace }), - ); - - // The server reloads settings.json while the page signs in; it scans once it opens. - await t3.open(); - await screen.getByRole("button", "Import 1 project and start").tap(); - const summary = screen.getByText("Imported 100 threads.", { exact: false }); - await summary.waitFor({ timeout: 60_000 }); - await app.screenshot("import-summary"); - - await expect(summary).toHaveText( - "Imported 100 threads. 1 thread was not imported yet. To import them, open the Welcome page again from Settings → About and select their projects under Review all.", - ); - } finally { - await runPromise(restore); - } - }, -);