Persist applied command status across reload (CS-11736)#5367
Open
FadhlanR wants to merge 2 commits into
Open
Conversation
An applied/invalid command on a streamed bot message reverted to "ready" after a page reload. The commandResult event links to the latest m.replace edit id (CS-11045 wire format), but reload strips all m.replace edits so only the original event survives — the host's two reload-side matchers keyed off the now-dangling event_id and the status flip was lost. Correlate both matchers (MessageBuilder.buildMessageCommand and RoomResource.updateMessageCommandResult) by the stable, globally-unique commandRequestId instead of the drifting event_id. The wire format is unchanged, so ai-bot prompt construction is untouched. Adds a host regression test that reproduces the post-reload state and asserts the command still renders applied. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Contributor
Preview deploymentsHost Test Results 1 files ±0 1 suites ±0 2h 32m 49s ⏱️ + 16m 37s Results for commit 065a27f. ± Comparison against earlier commit 44b5f16. Realm Server Test Results 1 files ±0 1 suites ±0 8m 56s ⏱️ - 1m 48s Results for commit 065a27f. ± Comparison against earlier commit 44b5f16. |
In updateMessageCommandResult, the commandRequestId lookup now fully determines the owning bot message, so the effectiveEventId fallback was unreachable. Hoist the missing-message early return and derive the cache key unconditionally from the located message. Add a regression test asserting an applied commandResult flips only its own bot message: a sibling message that also carries a command stays ready, confirming correlation by commandRequestId does not bleed across messages. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
lukemelia
approved these changes
Jun 30, 2026
lukemelia
left a comment
Contributor
There was a problem hiding this comment.
Need the /evergreen-comments skill applied
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.
Problem
After a command is applied in the AI assistant (most visibly an auto-executed command in
actmode), it showsappliedduring the session but reverts toreadyafter a page reload — the applied state isn't persisted.Root cause.
command-service.runstamps thecommandResultevent'sm.relates_to.event_idwith the latestm.replaceedit idYof the streamed bot message (intentional — CS-11045 — so the ai-bot's normalized/messagesview correlates correctly). On reload the timeline filter strips allm.replaceedits, so only the original eventXis loaded (with aggregated content) andYno longer exists as a distinct event. The host's two reload-side matchers still keyed offevent_id, so the danglingYlink broke and the status fell back to the literal default'ready'.Fix
Correlate both reload-side matchers by the stable, globally-unique
commandRequestId(the LLM tool-call id) instead of the driftingevent_id— mirroring the correlation the ai-bot already uses:MessageBuilder.buildMessageCommand— drop theevent_idcondition; match on type + rel_type +commandRequestId.RoomResource.updateMessageCommandResult— locate the owning bot message by "result'scommandRequestId∈ message's command-request ids" instead ofevent_idequality.The wire format (
event_id = Y) is unchanged, so ai-bot prompt construction / checkCorrectness behavior is untouched. The downstream_messageCachekey still resolves toXon both the live and reload paths.Screen Recording
Screen.Recording.2026-06-30.at.18.33.10.mov
Test
Adds a host regression test that reproduces the post-reload state directly (original message
Xcarrying the command request + acommandResultlinked to a stripped edit idY) and asserts the command still renders[data-test-apply-state="applied"]. Fails onmain, passes with this change.Linear: CS-11736
🤖 Generated with Claude Code