Repository navigation
fix: agent: an import that fails part-way says how far it got - #2048
Merged
lollipopkit merged 2 commits intoDec 3, 2026
Merged
Conversation
Each chat in an import rolls back on its own, so a failure on chat N left chats 1..N-1 written and published — but the import rethrew the raw error, and the UI showed an error sheet about the failure alone. The user had no way to know the first chats had landed: re-importing the same file then skips them (the plan is idempotent by id), and every count from there on is a mystery. A chat that fails after others landed now throws AgentChatImportPartial carrying the counts (imported, skipped) and the cause; the history page catches it and shows the same result line the success path does, with the failure under it. A first-chat failure — nothing landed — rethrows the plain error exactly as before, so callers matching on FormatException and the like keep working. The skipped count travels too: an archive whose only new chat breaks after N chats were skipped as already present now says so, rather than reporting a bare failure over a file that was mostly a no-op.
Contributor
Author
|
I have read the CLA Document and I hereby sign the CLA |
Contributor
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this changes
Each chat in an import rolls back on its own (session DB cleaned, no metadata written), so a failure on chat N left chats 1..N-1 written and published — but
AgentChatArchive.importrethrew the raw error, and the history page showed an error sheet about the failure alone. The user had no way to know the first chats had landed: re-importing the same file then skips them (the plan is idempotent by id), and every count from there on is a mystery.A chat that fails after others landed now throws
AgentChatImportPartialcarryingimported/skippedcounts and the cause; the history page catches it and shows the same result line the success path uses, with the failure underneath. A first-chat failure — nothing landed — rethrows the plain error exactly as before, so callers matching onFormatExceptionand the like keep working.The skipped count travels too: an archive whose only new chat breaks after N chats were skipped as already present now says so, rather than reporting a bare failure over a file that was mostly a no-op.
How it was tested
Three new tests in
agent_chat_archive_test.dart: chat 2 of 3 fails → the first stays written (session + metadata), the broken one rolls back, the third is never reached, and the exception carriesimported: 1; a first-chat failure still throws the plain error; skips are counted on a partial failure. All 9 tests in the file pass;flutter analyzeclean on all three touched files.Windows 11, Flutter 3.50.0. No ARB/l10n file changed (the partial sheet reuses the existing
agentImportResultstring), nocrates/change, no formatter run over untouched code.