diff --git a/apps/server/src/project/AgentSessionImporter.test.ts b/apps/server/src/project/AgentSessionImporter.test.ts index 18c0946144d4..cb19d0f31959 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 0f8736986a2d..b875c5c6ee9e 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 b6e1780bd039..e074ec53463b 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, @@ -2184,7 +2185,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") { @@ -2204,13 +2205,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 5c1b4218117f..ecc62b88b4f4 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,8 @@ function useProjectImport({ ? selection.filter((candidate) => importedProjects.has(candidate.key)).length : 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 () => { @@ -1656,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); @@ -1679,6 +1682,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, @@ -1689,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; @@ -1707,27 +1714,12 @@ 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, + requestFailed, + }); } finishAfterImport(); }; diff --git a/apps/web/src/i18n/translations/de.json b/apps/web/src/i18n/translations/de.json index 4c9f0f6d27e4..798a90fd4adf 100644 --- a/apps/web/src/i18n/translations/de.json +++ b/apps/web/src/i18n/translations/de.json @@ -2852,6 +2852,13 @@ "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.}}", + "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.", "a270f51c3f95de49": "Der Fehlerbericht konnte nicht in die Zwischenablage kopiert werden.", "09675b4ac9f858dc": "Ein unerwarteter Router-Fehler ist aufgetreten.", @@ -5940,10 +5947,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 c40470b46e6a..6270cbc807ca 100644 --- a/apps/web/src/i18n/translations/en.json +++ b/apps/web/src/i18n/translations/en.json @@ -2851,6 +2851,13 @@ "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.}}", + "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.", "a270f51c3f95de49": "Failed to copy error-report to the clipboard.", "09675b4ac9f858dc": "An unexpected router error occurred.", @@ -5941,10 +5948,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 68f63f589f51..f547ce5c7740 100644 --- a/apps/web/src/i18n/translations/es.json +++ b/apps/web/src/i18n/translations/es.json @@ -2851,6 +2851,13 @@ "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.}}", + "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.", "a270f51c3f95de49": "No se pudo copiar el informe de error al portapapeles.", "09675b4ac9f858dc": "Se produjo un error inesperado en el enrutador.", @@ -5939,10 +5946,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 442c22ed3a2d..ec94f321ba4f 100644 --- a/apps/web/src/i18n/translations/fr.json +++ b/apps/web/src/i18n/translations/fr.json @@ -2851,6 +2851,13 @@ "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.}}", + "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.", "a270f51c3f95de49": "Impossible de copier le rapport d’erreur dans le presse-papiers.", "09675b4ac9f858dc": "Une erreur de routage inattendue s’est produite.", @@ -5940,10 +5947,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 c9417551b208..53b946a43796 100644 --- a/apps/web/src/i18n/translations/ja.json +++ b/apps/web/src/i18n/translations/ja.json @@ -2849,6 +2849,13 @@ "5e4a0e56a0788d86": "記録された変更後の内容", "6d5a8b471a561b9d": "エクスプローラー", "83a174f9e78fe2f1": "ファイル", + "ce247a620407cec4": "{count, plural, other {{count} 件のスレッドをインポートしました。一部のスレッドの履歴はインポートできませんでした。}}", + "a0fd24f965eb070b": "スレッドの履歴をインポートできませんでした。", + "b79e42281b0acc9e": "{count, plural, other {{count} 件のスレッドをインポートしました。}}", + "686dd0744640be73": "{count, plural, other {{count} 件のスレッドをインポートできませんでした。}}", + "ed2f3077617c32f8": "一部のスレッドの履歴はインポートできませんでした。", + "a58e4704fffba164": "{count, plural, other {{count} 件のスレッドはまだインポートされていません。}}", + "8b8a18b159e8e1de": "インポートするには、設定 → 情報 からようこそページをもう一度開き、「すべてをレビュー」で対象のプロジェクトを選択してください。", "9c867852bab1ce60": "エラーレポートをコピーする際にクリップボード API を利用できませんでした。", "a270f51c3f95de49": "エラーレポートをクリップボードにコピーできませんでした。", "09675b4ac9f858dc": "予期しないルーターエラーが発生しました。", @@ -5921,10 +5928,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 362d29d071a8..e8b6ac29e52b 100644 --- a/apps/web/src/i18n/translations/ko.json +++ b/apps/web/src/i18n/translations/ko.json @@ -2850,6 +2850,13 @@ "5e4a0e56a0788d86": "변경 후 기록된 내용", "6d5a8b471a561b9d": "파일 탐색기", "83a174f9e78fe2f1": "파일", + "ce247a620407cec4": "{count, plural, other {스레드 {count}개를 가져왔습니다. 일부 스레드 기록은 가져올 수 없었습니다.}}", + "a0fd24f965eb070b": "스레드 기록을 가져올 수 없습니다.", + "b79e42281b0acc9e": "{count, plural, other {스레드 {count}개를 가져왔습니다.}}", + "686dd0744640be73": "{count, plural, other {스레드 {count}개를 가져올 수 없습니다.}}", + "ed2f3077617c32f8": "일부 스레드 기록은 가져올 수 없었습니다.", + "a58e4704fffba164": "{count, plural, other {스레드 {count}개를 아직 가져오지 않았습니다.}}", + "8b8a18b159e8e1de": "가져오려면 설정 → 정보에서 시작 페이지를 다시 열고 모두 검토에서 해당 프로젝트를 선택하세요.", "9c867852bab1ce60": "오류 보고서를 복사하는 중 클립보드 API를 사용할 수 없습니다.", "a270f51c3f95de49": "오류 보고서를 클립보드에 복사하지 못했습니다.", "09675b4ac9f858dc": "예기치 않은 라우터 오류가 발생했습니다.", @@ -5919,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/pt-BR.json b/apps/web/src/i18n/translations/pt-BR.json index b598943e9238..76ff9dc4a475 100644 --- a/apps/web/src/i18n/translations/pt-BR.json +++ b/apps/web/src/i18n/translations/pt-BR.json @@ -2851,6 +2851,13 @@ "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.}}", + "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.", "a270f51c3f95de49": "Falha ao copiar o relatório de erro para a área de transferência.", "09675b4ac9f858dc": "Ocorreu um erro inesperado no roteador.", @@ -5939,10 +5946,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 a8a54a6500e5..bb995209f62c 100644 --- a/apps/web/src/i18n/translations/ru.json +++ b/apps/web/src/i18n/translations/ru.json @@ -2851,6 +2851,13 @@ "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} треда.}}", + "ed2f3077617c32f8": "Часть истории тредов импортировать не удалось.", + "a58e4704fffba164": "{count, plural, one {{count} тред ещё не импортирован.} few {{count} треда ещё не импортированы.} many {{count} тредов ещё не импортированы.} other {{count} треда ещё не импортированы.}}", + "8b8a18b159e8e1de": "Чтобы импортировать их, снова откройте страницу приветствия в Настройки → О приложении и выберите их проекты в разделе «Просмотреть все».", "9c867852bab1ce60": "API буфера обмена недоступен при копировании отчёта об ошибке.", "a270f51c3f95de49": "Не удалось скопировать отчёт об ошибке в буфер обмена.", "09675b4ac9f858dc": "Непредвиденная ошибка маршрутизатора.", @@ -5939,10 +5946,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 adaf8566b641..7de481aeea0c 100644 --- a/apps/web/src/i18n/translations/sv.json +++ b/apps/web/src/i18n/translations/sv.json @@ -2851,6 +2851,13 @@ "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.}}", + "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.", "a270f51c3f95de49": "Kunde inte kopiera felrapporten till urklipp.", "09675b4ac9f858dc": "Ett oväntat routerfel uppstod.", @@ -5940,10 +5947,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 f386e717a061..175cf2eefa2c 100644 --- a/apps/web/src/i18n/translations/zh.json +++ b/apps/web/src/i18n/translations/zh.json @@ -2855,6 +2855,13 @@ "5e4a0e56a0788d86": "记录的内容(之后)", "6d5a8b471a561b9d": "文件资源管理器", "83a174f9e78fe2f1": "文件", + "ce247a620407cec4": "{count, plural, other {已导入 {count} 个会话。部分会话历史无法导入。}}", + "a0fd24f965eb070b": "无法导入会话历史。", + "b79e42281b0acc9e": "{count, plural, other {已导入 {count} 个会话。}}", + "686dd0744640be73": "{count, plural, other {{count} 个会话无法导入。}}", + "ed2f3077617c32f8": "部分会话历史无法导入。", + "a58e4704fffba164": "{count, plural, other {{count} 个会话尚未导入。}}", + "8b8a18b159e8e1de": "要导入它们,请从“设置 → 关于”再次打开欢迎页,并在“审查全部”中选择它们所属的项目。", "9c867852bab1ce60": "复制错误报告时剪贴板 API 不可用。", "a270f51c3f95de49": "无法将错误报告复制到剪贴板。", "09675b4ac9f858dc": "发生意外的路由错误。", @@ -5946,10 +5953,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 10cb0d731ee7..d62900bf8575 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,40 @@ 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, requestFailed: false }, + warning: `Imported 100 threads. 153 threads were not imported yet. ${resume}`, + }, + { + 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: 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, requestFailed: true }, + warning: "Imported 5 threads. Some thread history could not be imported.", + }, + { + totals: { imported: 0, failed: 0, deferred: 0, requestFailed: true }, + 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 1be9c7b824b2..4c717c521ad6 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,70 @@ 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; + readonly requestFailed: boolean; + }, + resolve: MessageResolver = m, +): string { + const { imported, failed, deferred, requestFailed } = 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 }, + ), + ), + ); + } else if (requestFailed) { + sentences.push(resolve(msg("Some thread history could not be imported."))); + } + 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 ed8e75c28c74..e7a5348e1b74 100644 --- a/docs/user/welcome-page.md +++ b/docs/user/welcome-page.md @@ -107,8 +107,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 93e0e36e4fbd..cb0350ccd8e6 100644 --- a/packages/contracts/src/agentSessions.ts +++ b/packages/contracts/src/agentSessions.ts @@ -75,6 +75,8 @@ export class AgentSessionImportProjectChangedError extends Schema.TaggedError