Skip to content

feat: remove msgpack support and replace with JSON#120

Merged
AnnatarHe merged 2 commits intomainfrom
claude/issue-117-20251003-0854
Oct 3, 2025
Merged

feat: remove msgpack support and replace with JSON#120
AnnatarHe merged 2 commits intomainfrom
claude/issue-117-20251003-0854

Conversation

@AnnatarHe
Copy link
Copy Markdown
Contributor

Fixes #117

This PR removes msgpack support from the entire project and replaces it with JSON encoding.

Changes

  • Removed msgpack struct tags from all model files
  • Replaced msgpack encoding/decoding with JSON in daemon socket communication
  • Updated daemon client and handlers to use JSON marshaling
  • Removed model/msgpack.go file completely
  • Removed legacy SendHTTPRequest function from api.base.go
  • Updated daemon/handlers_test.go to use JSON
  • Removed msgpack dependencies from go.mod

This change standardizes the project to use JSON encoding throughout, making it more maintainable and aligning with common software development practices.

Generated with Claude Code

- Remove msgpack struct tags from all model files
- Replace msgpack encoding/decoding with JSON in daemon socket communication
- Update daemon client and handlers to use JSON marshaling
- Remove model/msgpack.go file completely
- Remove legacy SendHTTPRequest function from api.base.go
- Update daemon/handlers_test.go to use JSON
- Remove msgpack dependencies from go.mod

This change standardizes the project to use JSON encoding throughout,
making it more maintainable and aligning with common software development practices.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Le He <AnnatarHe@users.noreply.github.com>
@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello @AnnatarHe, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request undertakes a significant refactoring effort to standardize the project's data serialization mechanism. By migrating entirely from Msgpack to JSON, the codebase becomes more consistent, easier to maintain, and aligns with widely adopted industry practices. This change impacts various components, from daemon communication to API models, ensuring a unified approach to data handling.

Highlights

  • Msgpack Removal: All Msgpack encoding/decoding logic and related dependencies have been completely removed from the project.
  • JSON Standardization: The project now exclusively uses JSON for data serialization, including daemon socket communication and API requests.
  • Model Struct Tag Updates: All model structs previously using msgpack tags have been updated to remove them, relying solely on json tags or default Go JSON marshaling behavior.
  • Legacy HTTP Request Function Removed: The deprecated SendHTTPRequest function, which used Msgpack, has been removed from model/api.base.go.
  • Dependency Clean-up: Msgpack-related dependencies (github.com/vmihailenco/msgpack/v5, github.com/ugorji/go/codec, github.com/vmihailenco/tagparser/v2) have been removed from go.mod.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request effectively replaces msgpack with JSON across the project, which is a great move for standardization and maintainability. The changes are applied consistently. I've identified an area for performance improvement in daemon/handlers.sync.go to avoid an unnecessary marshal/unmarshal cycle. Also, it seems model/msgpack_test.go was left behind and should be removed to prevent build failures. Other than that, the changes look good.

Comment thread daemon/handlers.sync.go
Comment on lines +13 to +20
pb, err := json.Marshal(socketMsgPayload)
if err != nil {
slog.Error("Failed to marshal the sync payload again for unmarshal", slog.Any("payload", socketMsgPayload))
return err
}

var syncMsg model.PostTrackArgs
err = msgpack.Unmarshal(pb, &syncMsg)
err = json.Unmarshal(pb, &syncMsg)
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.

medium

This function marshals socketMsgPayload to JSON and then immediately unmarshals it back into syncMsg. This is an inefficient pattern involving an unnecessary serialization and deserialization cycle. Since socketMsgPayload is already a map[string]interface{} in memory after the initial JSON decoding, this double-conversion should be avoided.

A better approach would be to refactor the data handling. For instance, you could change SocketMessage.Payload in daemon/socket.go to be of type json.RawMessage. This would allow you to unmarshal the payload directly into the target model.PostTrackArgs struct in the handler, eliminating the intermediate marshaling step and improving performance.

Remove msgpack_test.go that was left behind after msgpack support was removed
in commit 6a8229e. The msgpack functionality has been replaced with JSON.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
@codecov
Copy link
Copy Markdown

codecov Bot commented Oct 3, 2025

Codecov Report

❌ Patch coverage is 50.00000% with 3 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
daemon/socket.go 0.00% 2 Missing ⚠️
daemon/client.go 0.00% 1 Missing ⚠️
Flag Coverage Δ
unittests 20.75% <50.00%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
daemon/handlers.go 100.00% <100.00%> (ø)
daemon/handlers.sync.go 67.04% <100.00%> (ø)
model/alias.go 0.00% <ø> (ø)
model/api.base.go 30.00% <ø> (+12.16%) ⬆️
model/api.go 100.00% <ø> (ø)
model/ccusage_service.go 0.00% <ø> (ø)
model/dotfile.go 0.00% <ø> (ø)
model/handshake.go 61.29% <ø> (ø)
daemon/client.go 0.00% <0.00%> (ø)
daemon/socket.go 0.00% <0.00%> (ø)

... and 1 file with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@AnnatarHe AnnatarHe merged commit 64a87e7 into main Oct 3, 2025
3 checks passed
@AnnatarHe AnnatarHe deleted the claude/issue-117-20251003-0854 branch October 3, 2025 12:23
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.

feat: remove msgpack support in whole project

1 participant