Skip to content

fix(migration-legacy): correct blank-title and corrupt-classification on kimi-cli import#729

Open
Dmatut7 wants to merge 3 commits into
MoonshotAI:mainfrom
Dmatut7:fix/migration-import-edge-cases
Open

fix(migration-legacy): correct blank-title and corrupt-classification on kimi-cli import#729
Dmatut7 wants to merge 3 commits into
MoonshotAI:mainfrom
Dmatut7:fix/migration-import-edge-cases

Conversation

@Dmatut7

@Dmatut7 Dmatut7 commented Jun 13, 2026

Copy link
Copy Markdown

Related Issue

No existing issue — two kimi-cli import edge cases explained below.

Problem

When importing legacy kimi-cli sessions: (1) a whitespace-only custom_title (e.g. " ") was written verbatim as the session title and flagged isCustomTitle: true, surfacing an all-spaces, falsely-custom entry in the picker; (2) analyzeContextContent classified a context.jsonl whose lines are valid JSON but not objects (42, "hi", []) as corrupt — even though its own doc comment defines corrupt as "every non-blank line failed to parse" — so such a session was reported as a migration failure instead of empty/skipped.

What changed

(1) Trim custom_title and treat a blank result as absent (mirroring fallbackTitle), so it falls back to the prompt prefix and isCustomTitle is false. (2) Mark a line as parseable as soon as JSON.parse succeeds, before the object-shape check, so an all-valid-JSON-non-object context is empty, not corrupt. Genuinely truncated lines still fail to parse and remain corrupt. Tests added for both.

Checklist

  • I have read the CONTRIBUTING document.
  • I have explained the problem above.
  • I have added tests (fail-before/pass-after).
  • Changeset included (patch, @moonshot-ai/kimi-code).
  • This PR needs no doc update.

Dmatut7 and others added 3 commits June 14, 2026 03:46
…ing sessions

A whitespace-only `custom_title` (e.g. "   ") on an imported kimi-cli
session was written verbatim as the session title and flagged
`isCustomTitle: true`. The length guards (`custom_title.length > 0`) only
counted characters, never trimming, while the sibling `fallbackTitle` is
trimmed — so a blank title slipped past and surfaced as an all-spaces,
falsely-custom entry in the session picker.

Trim the custom_title and treat a blank result as absent, so the title
falls back to the prompt prefix (or "Imported session") and isCustomTitle
is false. Non-blank titles are now also trimmed, matching fallbackTitle.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…corrupt

`analyzeContextContent` documents `corrupt` as "every non-blank line
failed to parse" (disk damage / truncated write). But a line that
JSON.parse accepted yet was a scalar/array (e.g. `42`, `"hi"`, `[]`) hit
the object-shape `continue` before `hadParseableLine` was set, so a
context of all valid-JSON non-objects was misreported as `corrupt` and
surfaced as a migration failure instead of an empty/skipped session.

Mark the line as parseable as soon as JSON.parse succeeds, before the
shape check — matching the documented contract and the existing
"at least one line parses → empty" test intent. Genuinely truncated
lines still fail JSON.parse and remain `corrupt`.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@changeset-bot

changeset-bot Bot commented Jun 13, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 8ce41d7

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@moonshot-ai/kimi-code Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

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.

1 participant