feat(projects): POST /v1/projects/{id}/heartbeat (#106) - #128
Merged
Conversation
ProjectRepoAdapter.startHeartbeatWorker points a SharedWorker at this path on a timer; no route existed, so every tick 404'd and after the stale threshold each open editor was told its session had gone stale. Chose 'add the endpoint' over 'locking is client-only' because the two concerns are already separate: the edit lock lives in the git-backed project repo and is written by the client, while the worker only needs to know whether the backend is reachable and still knows the project. That is a real signal a client cannot derive on its own, and it is what the stale-session banner should reflect. Deliberately does no writes — it runs per open editor on a short interval, and carries no state the lock file does not already hold. 404 for an unknown project, which the worker treats as a failed tick.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #106.
ProjectRepoAdapter.startHeartbeatWorker(adapter.ts:231) points a SharedWorker at this path on a timer. No route existed, so every tick 404'd and once the stale threshold passed, each open editor was told its session had gone stale.Why add the endpoint rather than make locking client-only
The issue framed it as either/or, but the two concerns are already separate in the code:
ProjectRepoAdapter.writeLock) — the backend has no lock model and does not need oneSo the endpoint is liveness only. It deliberately does no writes: it runs per open editor on a short interval, and carries no state the lock file does not already hold.
204 when the project exists, 404 otherwise — the worker treats a failed tick as a step toward
stale.Tests
Known project → 204 with an empty body; unknown → 404 with the
NOT_FOUNDenvelope; and five consecutive pings leave the project row byte-identical, pinning the no-writes property.467 passed, ruff clean,
openapi.jsonregenerated.