Skip to content

Couple LongRunningCommandAgentInteractionState with block id#27

Merged
seemeroland merged 2 commits into
mainfrom
roland/lrc-update-should-apply-to-specific-block
Jun 9, 2026
Merged

Couple LongRunningCommandAgentInteractionState with block id#27
seemeroland merged 2 commits into
mainfrom
roland/lrc-update-should-apply-to-specific-block

Conversation

@seemeroland

@seemeroland seemeroland commented Jun 8, 2026

Copy link
Copy Markdown
Contributor

Comment thread src/common/ui_state.rs

/// How the agent is interacting with the current long running command (if at all).
/// Deprecated in favor of long_running_command_agent_interaction.
pub long_running_command_agent_interaction_state:

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

should also skip serializing if this is None, no?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yea might as well add it now. Technically just need #[serde(default)] once the field is no longer populated

Comment thread src/common/ui_state.rs

/// How the agent is interacting with a specific long running command block.
#[derive(Clone, Debug, Deserialize, Serialize, PartialEq, Eq)]
pub struct LongRunningCommandAgentInteraction {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Rather than adding a separate type and having to deal with migrating from one LRC type to another, I actually think it could be ok to just add active_block_id as a sibling field? Is that enough to determine if the update should be applied (wouldn't block_id as populated by the sharer always be the active block ID)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

then you don't have to deal with a semantic either/or migration for the new field and old field, can just say there is a new field only supported by newer clients?

@seemeroland seemeroland Jun 9, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The complication with that is that UniversalDeveloperInputContext is a merging of several sources of writes to a shared cache. If we put active block id on this, it would either need to be populated on every source (and probably all of these updates should be guarded on matching block id), or we say it's specifically for the LRC update which is weirder imo.

I think coupling to LRC update is what I want. For this update we need the block id to come from the source of updating LRC state, not the active block id at time of sending UniversalDeveloperInputContext

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

i see

@seemeroland seemeroland merged commit b30fdd0 into main Jun 9, 2026
5 checks passed
@seemeroland seemeroland deleted the roland/lrc-update-should-apply-to-specific-block branch June 9, 2026 00:04
seemeroland added a commit to warpdotdev/warp that referenced this pull request Jun 9, 2026
## Description

Was investigating sources of ambient agent tasks becoming canceled by
user automatically:
https://linear.app/warpdotdev/issue/REMOTE-1887/maa-requests-getting-canceled#comment-75459dec

It can happen when we receive a NotInteracting LRC state, which is
interpreted as user takeover of a CLI subagent monitored requested
command. This is meant to cancel the conversation stream because the
agent is no longer monitoring, but it also set the conversation status
to canceled, which updates the ambient agent state to canceled by user.

But I also see the sharer receiving NotInteracting from the viewer when
not expected. I believe there may be stale updates from the viewer
causing this. We definitely should have LRC state updates apply to a
specific block so we can discard stale updates.

And finally, some bugs with cloud mode were causing echoes of LRC state
updates. The problematic flow was:
- Sharer updates LRC state, fans out result
- Cloud mode viewer applies LRC update from sharer locally
- But cloud mode viewer mutation locally would result in LRC update,
which gets fanned out to sharer because cloud mode viewer has write
permission
- Sharer receives echo of its LRC update, as if viewer wrote it

So this is a combination of 3 fixes:
- User takeover of a LRC should keep the conversation and task status in
progress
- In shared sessions, LRC state updates should apply to specific blocks
so stale updates can't apply
- Prevent viewer replaying sharer LRC updates from writing again to
shared session

Requires protocol change to be merged first, before updating cargo.toml:
warpdotdev/session-sharing-protocol#27

## Testing
<!--
How did you test this change? What automated tests did you add? If you
didn't add any new tests, what's your justification for not adding any?

Manual testing is required for changes that can be manually tested, and
almost all changes can be manually tested. If your change can be
manually tested, please include screenshots or a screen recording that
show it working end to end.

You can run the app locally using `./script/run` - see WARP.md for more
details on how to get set up.
-->

- [x] I have manually tested my changes locally with `./script/run`

### Screenshots / Videos
<!-- Attach screenshots or a short video demonstrating the change, where
appropriate. Remove this section if it is not relevant to your PR. -->

Tested with
warpdotdev/session-sharing-protocol#27

https://www.loom.com/share/f09e7b1d7e35412a99a7c2947104a460
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants