Skip to content

[fix] kimi_cli failed to find CHANGELOG.md#1277

Open
ClSlaid wants to merge 4 commits intoMoonshotAI:mainfrom
ClSlaid:fix/lazy-changelog
Open

[fix] kimi_cli failed to find CHANGELOG.md#1277
ClSlaid wants to merge 4 commits intoMoonshotAI:mainfrom
ClSlaid:fix/lazy-changelog

Conversation

@ClSlaid
Copy link
Copy Markdown

@ClSlaid ClSlaid commented Feb 27, 2026

Pyinstaller packed binary will extract itself
and then run. However, it does not extract the
CHANGELOG.md at the first place, thus lead to
instant failure on starting the program.

This patch makes reading CHANGELOG.md file lazy,
then the file will only be read once when running
instead of starting.

Related Issue

Discribed in PR.

Checklist

  • I have read the CONTRIBUTING document.
  • I have linked the related issue, if any.
  • I have added tests that prove my fix is effective or that my feature works.
  • I have run make gen-changelog to update the changelog.
  • I have run make gen-docs to update the user documentation.

Open with Devin

Pyinstaller packed binary will extract itself
and then run. However, it does not extract the
CHANGELOG.md at the first place, thus lead to
instant failure on starting the program.

This patch makes reading CHANGELOG.md file lazy,
then the file will only be read once when running
instead of starting.

Signed-off-by: cl <[email protected]>
Copilot AI review requested due to automatic review settings February 27, 2026 10:35
Copy link
Copy Markdown
Contributor

@devin-ai-integration devin-ai-integration bot left a comment

Choose a reason for hiding this comment

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

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no potential bugs to report.

View in Devin Review to see 3 additional findings.

Open in Devin Review

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes an issue where PyInstaller-packed binaries fail at startup because CHANGELOG.md is not immediately available when the module is imported. The solution converts the eager loading of CHANGELOG.md (at module import time) to lazy loading (on first access), preventing the startup failure.

Changes:

  • Replaced module-level CHANGELOG constant with a lazy-loading get_changelog() function that caches the parsed changelog on first access
  • Updated the /changelog command to call get_changelog() instead of using the CHANGELOG constant
  • Added graceful FileNotFoundError handling that returns an empty changelog if the file is missing

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.

File Description
src/kimi_cli/utils/changelog.py Introduced lazy loading for CHANGELOG.md with caching and error handling; minor formatting change to ReleaseEntry construction
src/kimi_cli/ui/shell/slash.py Updated import and usage from CHANGELOG constant to get_changelog() function

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +110 to +120
def get_changelog() -> dict[str, ReleaseEntry]:
"""Lazily load and parse the changelog on first access."""
global _cached_changelog
if _cached_changelog is None:
path = Path(__file__).parent.parent / "CHANGELOG.md"
try:
_cached_changelog = parse_changelog(
path.read_text(encoding="utf-8"))
except FileNotFoundError:
_cached_changelog = {}
return _cached_changelog
Copy link

Copilot AI Feb 27, 2026

Choose a reason for hiding this comment

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

The new lazy loading mechanism lacks test coverage. While the existing test for parse_changelog will continue to work, there's no test that verifies the lazy loading behavior, the caching mechanism, or the FileNotFoundError handling. Consider adding a test that verifies: 1) the changelog is only loaded once (caching works), 2) calling get_changelog multiple times returns the same cached result, and 3) graceful handling when CHANGELOG.md is missing.

Copilot uses AI. Check for mistakes.
Co-authored-by: Copilot <[email protected]>
Signed-off-by: ClSlaid <[email protected]>
Copy link
Copy Markdown
Contributor

@devin-ai-integration devin-ai-integration bot left a comment

Choose a reason for hiding this comment

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

Devin Review found 1 new potential issue.

View 7 additional findings in Devin Review.

Open in Devin Review

@@ -121,7 +122,7 @@ Only write entries that are worth mentioning to users.
- Web: Fix authentication token persistence by switching from sessionStorage to localStorage with 24-hour expiry
- Web: Add server-side pagination for session list with virtualized scrolling for better performance
- Web: Improve session and work directories loading with smarter caching and invalidation
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.

🟡 v1.7.0 changelog entry replaced with duplicate of v1.6 entry

In CHANGELOG.md, the v1.7.0 entry Web: Fix WebSocket errors during history replay by checking connection state before sending was replaced with Web: Fix WebSocket disconnect when creating new sessions. However, that exact same text already exists in the v1.6 section at line 133. This means v1.7.0 now has a duplicate of the v1.6 fix note, and the original v1.7.0 fix description (which described a different bug fix — checking connection state before sending during history replay) is lost. The same duplication occurs in docs/en/release-notes/changelog.md at line 118 vs line 127.

Suggested change
- Web: Improve session and work directories loading with smarter caching and invalidation
- Web: Fix WebSocket errors during history replay by checking connection state before sending
Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

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