fix: clear stale turn state and unblock stuck composer sends#1715
fix: clear stale turn state and unblock stuck composer sends#1715justsomelegs wants to merge 4 commits intopingdotgg:mainfrom
Conversation
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
ApprovabilityVerdict: Needs human review This bug fix changes fundamental client-server state synchronization patterns, replacing timestamp-based acknowledgment with sequence-based tracking, and adds server restart detection that triggers page reloads. While well-tested, the scope of runtime behavior changes to core state management warrants human review. You can customize Macroscope's approvability policy. Learn more. |
What Changed
Fixes #1048, #593.
This PR fixes the stuck
waiting/Sendingstate in two small steps:It fixes stale orchestration session state on the server.
When provider runtime lifecycle events transition a session back out of
running, we now clear any staleactiveTurnIdinstead of carrying it forward. The lifecycle guard also only treatsactiveTurnIdas authoritative while the session is actuallyrunning.It makes the web composer acknowledge sends by committed orchestration sequence instead of inferring acknowledgement from thread/session timestamps.
The local send latch now clears when the client has applied the
dispatchCommand(...).sequencefor the send, and snapshot sync keeps that applied-sequence value monotonic.There is also a small reconnect safeguard:
serverInstanceIdWhy
The issue had two contributing pieces:
readywhile still retaining a staleactiveTurnId. Later turn lifecycle events could then be treated as conflicting/stale.Sendingand block another message until refresh or thread switch.This approach keeps the fix focused:
That is more robust than the old timestamp-based inference, while still keeping the PR scoped to a bug fix.
Checklist
For the last two items: there are no meaningful UI visuals to screenshot here. This is a state-management/reliability fix rather than a presentational UI change.
Note
Fix stuck composer by unblocking sends via orchestration sequence acknowledgment
hasServerAcknowledgedLocalDispatchwith an orchestration sequence check: the composer unblocks whenlatestAppliedOrchestrationSequencemeets or exceeds theackSequencereturned from the server after dispatch.activeTurnIdinProviderRuntimeIngestionwhenever the session transitions to a non-running state (ready, error, stopped), not just onturn.completedorsession.exited.serverInstanceId(random UUID) to welcome payloads and triggers a full page reload in the client when a welcome arrives from a different server instance after initial connection.latestAppliedOrchestrationSequenceinAppState, updated on every applied orchestration event and read model sync.Macroscope summarized 927191a.