Skip to content

fix: agent: an import that fails part-way says how far it got - #2048

Merged
lollipopkit merged 2 commits into
lollipopkit:mainfrom
pwu2775-dev:fix/agent-import-partial-feedback
Dec 3, 2026
Merged

lollipopkit merged 2 commits into
lollipopkit:mainfrom
pwu2775-dev:fix/agent-import-partial-feedback

Conversation

@pwu2775-dev

Copy link
Copy Markdown
Contributor

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.import rethrew 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 AgentChatImportPartial carrying imported/skipped counts 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 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.

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 carries imported: 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 analyze clean on all three touched files.

Windows 11, Flutter 3.50.0. No ARB/l10n file changed (the partial sheet reuses the existing agentImportResult string), no crates/ change, no formatter run over untouched code.

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.
@pwu2775-dev

Copy link
Copy Markdown
Contributor Author

I have read the CLA Document and I hereby sign the CLA

@coderabbitai

coderabbitai Bot commented Dec 3, 2026 •

Copy link
Copy Markdown
Contributor

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Essentials
  • Run ID: f19de5dc-8c08-4a15-97d2-922a08a0fef6

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

@lollipopkit
lollipopkit merged commit 36429d1 into lollipopkit:main Dec 3, 2026
21 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants