Skip to content

fix(daemon): add acknowledgment response for heartbeat messages#177

Merged
AnnatarHe merged 1 commit intomainfrom
fix/heartbeat-acknowledgment
Dec 28, 2025
Merged

fix(daemon): add acknowledgment response for heartbeat messages#177
AnnatarHe merged 1 commit intomainfrom
fix/heartbeat-acknowledgment

Conversation

@AnnatarHe
Copy link
Copy Markdown
Contributor

Summary

  • Send {"status":"ok"} after processing heartbeat message
  • Send {"status":"disabled"} when codeTracking is disabled

Problem

The VS Code extension showed "daemon not running" warning even when the daemon was running. The root cause was that the daemon didn't send any response for heartbeat messages, causing the extension to interpret the empty response as a connection failure.

Solution

Add acknowledgment responses for heartbeat messages:

  • {"status":"ok"} - heartbeat was received and published to PubSub
  • {"status":"disabled"} - codeTracking is disabled, heartbeat was ignored

Test plan

  • Enable codeTracking, send heartbeat - should receive {"status":"ok"}
  • Disable codeTracking, send heartbeat - should receive {"status":"disabled"}
  • VS Code extension should show "Connected" status after heartbeat

🤖 Generated with Claude Code

- Send {"status":"ok"} after processing heartbeat message
- Send {"status":"disabled"} when codeTracking is disabled
- Fixes VS Code extension incorrectly showing "daemon not running"

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.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 addresses a critical communication gap between the daemon and the VS Code extension. Previously, the absence of a response to heartbeat messages led the extension to misinterpret the daemon's operational status. The changes introduce explicit acknowledgment responses, ensuring the extension accurately reflects whether the daemon is running and if codeTracking is enabled or disabled, thereby improving user experience and system reliability.

Highlights

  • Heartbeat Acknowledgment: The daemon now sends an acknowledgment response to heartbeat messages, resolving an issue where the VS Code extension incorrectly reported the daemon as not running due to a lack of response.
  • Status Responses: Two distinct status messages are sent: {"status":"ok"} when a heartbeat is successfully processed and published, and {"status":"disabled"} if codeTracking is inactive, providing clear feedback to the client.
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.

@AnnatarHe AnnatarHe merged commit d4a2ed9 into main Dec 28, 2025
2 checks passed
@AnnatarHe AnnatarHe deleted the fix/heartbeat-acknowledgment branch December 28, 2025 07:48
@codecov
Copy link
Copy Markdown

codecov Bot commented Dec 28, 2025

Codecov Report

❌ Patch coverage is 0% with 4 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
daemon/socket.go 0.00% 4 Missing ⚠️
Flag Coverage Δ
unittests 20.05% <0.00%> (?)

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

Files with missing lines Coverage Δ
daemon/socket.go 0.00% <0.00%> (ø)

... and 2 files with indirect coverage changes

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

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 correctly adds acknowledgment responses for heartbeat messages, which resolves the issue with the VS Code extension. The logic is sound. However, the implementation misses error handling for the JSON encoding operations in both new code blocks. This could lead to silent failures. The provided comments highlight these issues and suggest adding the necessary error checking and logging, which will make the code more robust.

Comment thread daemon/socket.go
if p.config.CodeTracking == nil || p.config.CodeTracking.Enabled == nil || !*p.config.CodeTracking.Enabled {
slog.Debug("Heartbeat message received but codeTracking is disabled, ignoring")
encoder := json.NewEncoder(conn)
encoder.Encode(map[string]string{"status": "disabled"})
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

The error returned by encoder.Encode is not handled. This could lead to silent failures if writing the response to the connection fails. It's important to check for errors and log them to ensure robust operation, similar to how it's handled in the handleStatus function.

if err := encoder.Encode(map[string]string{"status": "disabled"}); err != nil {
				slog.Error("Error encoding 'disabled' status response", slog.Any("err", err))
			}

Comment thread daemon/socket.go

// Send acknowledgment to client
encoder := json.NewEncoder(conn)
encoder.Encode(map[string]string{"status": "ok"})
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

Similar to the other change, the error from encoder.Encode is not handled here. Please add error checking and logging to prevent silent failures when sending the acknowledgment.

if err := encoder.Encode(map[string]string{"status": "ok"}); err != nil {
			slog.Error("Error encoding 'ok' status response", slog.Any("err", err))
		}

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