Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 28 additions & 1 deletion src/common/ui_state.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use serde::{Deserialize, Serialize};

use crate::common::ServerConversationToken;
use crate::common::{BlockId, ServerConversationToken};

/// The active base model selection for agent mode.
/// This represents the UI state of which model is selected in the model picker chip.
Expand Down Expand Up @@ -112,6 +112,13 @@ pub enum LongRunningCommandAgentInteractionState {
InControl,
}

/// 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

pub block_id: BlockId,
pub state: LongRunningCommandAgentInteractionState,
}

/// The combined state container for universal developer input context.
/// This includes model selection, input mode, and selected conversation.
#[derive(Clone, Debug, Deserialize, Serialize, Default, PartialEq, Eq)]
Expand All @@ -126,9 +133,15 @@ pub struct UniversalDeveloperInputContext {
pub selected_conversation: Option<SelectedConversation>,

/// How the agent is interacting with the current long running command (if at all).
/// Deprecated in favor of long_running_command_agent_interaction.
#[serde(default, skip_serializing_if = "Option::is_none")]
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

Option<LongRunningCommandAgentInteractionState>,

/// How the agent is interacting with a specific long running command block, if any.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub long_running_command_agent_interaction: Option<LongRunningCommandAgentInteraction>,

/// Whether auto-approve is enabled for agent actions.
pub auto_approve_agent_actions: Option<bool>,

Expand All @@ -154,6 +167,10 @@ pub struct UniversalDeveloperInputContextUpdate {
pub long_running_command_agent_interaction_state:
Option<LongRunningCommandAgentInteractionState>,

/// How the agent is interacting with a specific long running command block, if any.
#[serde(skip_serializing_if = "Option::is_none")]
pub long_running_command_agent_interaction: Option<LongRunningCommandAgentInteraction>,

#[serde(skip_serializing_if = "Option::is_none")]
pub auto_approve_agent_actions: Option<bool>,

Expand All @@ -173,6 +190,7 @@ impl UniversalDeveloperInputContextUpdate {
auto_approve_agent_actions: updated_auto_approve_agent_actions,
long_running_command_agent_interaction_state:
updated_long_running_command_agent_interaction_state,
long_running_command_agent_interaction: updated_long_running_command_agent_interaction,
cli_agent_session: updated_cli_agent_session,
} = self;
let UniversalDeveloperInputContext {
Expand All @@ -182,6 +200,7 @@ impl UniversalDeveloperInputContextUpdate {
auto_approve_agent_actions: cached_auto_approve_agent_actions,
long_running_command_agent_interaction_state:
cached_long_running_command_agent_interaction_state,
long_running_command_agent_interaction: cached_long_running_command_agent_interaction,
cli_agent_session: cached_cli_agent_session,
} = cached;

Expand All @@ -198,6 +217,9 @@ impl UniversalDeveloperInputContextUpdate {
|| (updated_long_running_command_agent_interaction_state.is_some()
&& updated_long_running_command_agent_interaction_state
!= cached_long_running_command_agent_interaction_state)
|| (updated_long_running_command_agent_interaction.is_some()
&& updated_long_running_command_agent_interaction.as_ref()
!= cached_long_running_command_agent_interaction.as_ref())
|| (updated_cli_agent_session.is_some()
&& updated_cli_agent_session.as_ref() != Some(cached_cli_agent_session))
}
Expand All @@ -214,6 +236,7 @@ impl UniversalDeveloperInputContextUpdate {
auto_approve_agent_actions: updated_auto_approve_agent_actions,
long_running_command_agent_interaction_state:
updated_long_running_command_agent_interaction_state,
long_running_command_agent_interaction: updated_long_running_command_agent_interaction,
cli_agent_session: updated_cli_agent_session,
} = self;
let UniversalDeveloperInputContext {
Expand All @@ -223,6 +246,7 @@ impl UniversalDeveloperInputContextUpdate {
auto_approve_agent_actions: current_auto_approve_agent_actions,
long_running_command_agent_interaction_state:
current_long_running_command_agent_interaction_state,
long_running_command_agent_interaction: current_long_running_command_agent_interaction,
cli_agent_session: current_cli_agent_session,
} = current;

Expand All @@ -235,6 +259,8 @@ impl UniversalDeveloperInputContextUpdate {
long_running_command_agent_interaction_state:
updated_long_running_command_agent_interaction_state
.or(current_long_running_command_agent_interaction_state),
long_running_command_agent_interaction: updated_long_running_command_agent_interaction
.or(current_long_running_command_agent_interaction),
cli_agent_session: updated_cli_agent_session.unwrap_or(current_cli_agent_session),
}
}
Expand All @@ -249,6 +275,7 @@ impl From<UniversalDeveloperInputContext> for UniversalDeveloperInputContextUpda
auto_approve_agent_actions: context.auto_approve_agent_actions,
long_running_command_agent_interaction_state: context
.long_running_command_agent_interaction_state,
long_running_command_agent_interaction: context.long_running_command_agent_interaction,
cli_agent_session: Some(context.cli_agent_session),
}
}
Expand Down