Skip to content

Migration error handling#8010

Merged
imanolmzd-svg merged 78 commits intomainfrom
imanol/migration-error-handling
Mar 31, 2026
Merged

Migration error handling#8010
imanolmzd-svg merged 78 commits intomainfrom
imanol/migration-error-handling

Conversation

@imanolmzd-svg
Copy link
Copy Markdown
Contributor

Context

  • Adds error handling so that users see an error on Session migration. See video attached.

  • Temporarily commenting out the option to "Delete all Legacy Settings" so users can retry migration or go back to the old extension if migration fails.

  • Known limitation: Only handles session migration at the moment. Doesn't cover failures migrating other elements.

Video

Screen.Recording.2026-03-31.at.12.31.22.mov

Testing

  • Forced an error on the backend to trigger the error view
  • Checked I can copy the error
  • Checked with no errors that the conversations are migrated correctly

…r check

Move `disposeGlobal` call inside the success-only branch so the
extension is not torn down when migration partially fails. Similarly,
defer the `loadSessions` webview message to the "Continue" button on
the error screen so sessions are only reloaded after the user
acknowledges the failure.

- `handleStartLegacyMigration`: move `disposeGlobal` inside the
  `!failed && success` guard to avoid disposing on partial failure
- `MigrationWizard`: skip `loadSessions` post-message when errors are
  present; send it from the "Continue" button instead
…tor utilities

Replace inline error text rendering in MigrationWizard with a dedicated
MigrationError component that displays a structured error box with a
copy-to-clipboard action. Extract error parsing logic into reusable
selector functions in a separate module.

- Add `MigrationError` component with header, detail text, and
  preformatted error code block; copy button writes error to clipboard
  and shows a success toast
- Add `error-selectors.ts` with `getMigrationError` (strips error type
  prefix), `getSessionMigrationError`, and `getSessionMigrationErrorDetail`
- Replace `<Show>` + raw `error-text` div in MigrationWizard sessions
  row with `<MigrationError>` using the new selector-derived signals
…vations

Extract `ProgressEntry` type and inline derived-state functions from
`MigrationWizard` into a dedicated `migration-view-model.ts` module,
and update call sites to use the new public API.

- Add `migration-view-model.ts` exporting `ProgressEntry`, `getGroupStatus`,
  `getGroupMessage`, `getSuccessCount`, `getTotalCount`,
  `getCurrentSessionError`, and `getCurrentSessionErrorDetail`
- Remove duplicated logic from `MigrationWizard` and delegate to the
  new module, keeping the component focused on rendering concerns
- Consolidate the `getGroupMessage` resolver used by error selectors so
  it is derived from a single source of truth
Move `MigrationResultItem` out of `legacy-types.ts` into a new
`migration-types.ts` module, and introduce a `MigrationFailure`
typed error structure in `errors/migration-failure.ts`.

- Add `migration-types.ts` exporting `MigrationResultItem` to separate
  runtime migration result types from legacy configuration types
- Add `errors/migration-failure.ts` defining `MigrationFailure` and
  `MigrationFailureKind` for structured error classification
- Remove `MigrationResultItem` from `legacy-types.ts` to eliminate
  the coupling between legacy config shapes and migration output types
- Update `migration-service.ts` import to reference the new module
Introduce `migration-error.ts` with `normalizeMigrationError` and
`getMigrationErrorMessage` to convert arbitrary thrown values into
typed `MigrationFailure` objects.

- Classify errors by kind (`http`, `sdk`, `generic`, `unknown`) based
  on the presence of `status`, `data`, `body`, or `Error` instance
- Extract human-readable message from `message`, `body`, `data`, or
  raw string fallback, defaulting to "Unknown migration error"
- Compose a `detail` string from status code, body, and data fields
  when they differ from the primary message
- Propagate nested `cause` text for additional diagnostic context
Remove the separately extracted `migration-view-model.ts`, `error-selectors.ts`,
`MigrationError.tsx`, and `MigrationFailure` type in favour of inlined logic
directly in `MigrationWizard` and a simplified `getMigrationErrorMessage`
utility.

- Delete `MigrationFailure` type and `normalizeMigrationError`; replace with
  a flat `getMigrationErrorMessage` function
- Inline `ProgressEntry` interface, group-status logic, and count helpers
  into `MigrationWizard`
- Replace `MigrationError` component with inline clipboard copy handler
  using `showToast`
- Simplify session migrate result shape: drop structured `error` field,
  surface plain `message` string instead
…wizard

Add CSS for the error display box and copy-to-clipboard button in the
migration wizard, including layout, typography, theming via VSCode CSS
variables, hover/active/focus-visible states, and high-contrast border
overrides. Also align wizard items to flex-start for multi-line content.
</Show>

{/* Cleanup option after done */}
{/*
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this code commented out?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shows the following button - Which deletes legacy settings. I think the cautious move for now is to not have it in place.

Screen.Recording.2026-03-31.at.17.48.54.mov

Comment thread packages/kilo-vscode/webview-ui/src/components/migration/MigrationWizard.tsx Outdated
Comment thread packages/opencode/src/kilocode/session-import/service.ts Outdated
Comment thread packages/kilo-vscode/webview-ui/src/components/migration/MigrationWizard.tsx Outdated
@kilo-code-bot
Copy link
Copy Markdown
Contributor

kilo-code-bot bot commented Mar 31, 2026

Code Review Summary

Status: No Issues Found | Recommendation: Merge

Files Reviewed (2 files)
  • packages/kilo-vscode/src/legacy-migration/migration-service.ts
  • packages/kilo-vscode/webview-ui/src/components/migration/MigrationWizard.tsx

Reviewed by gpt-5.4-20260305 · 216,800 tokens

Comment thread packages/kilo-vscode/src/legacy-migration/migration-service.ts Outdated
… all sessions

Replace the single "Chat sessions" progress item with per-session
tracking, passing the session ID directly to onProgress calls and
mapping each session to its own pending item in the wizard's progress
list.
@imanolmzd-svg imanolmzd-svg merged commit d6eeb00 into main Mar 31, 2026
14 checks passed
@imanolmzd-svg imanolmzd-svg deleted the imanol/migration-error-handling branch March 31, 2026 17:06
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.

3 participants