first pass of merging in warp (doesn't build)

This commit is contained in:
Ryan Ward
2026-07-01 16:08:58 -05:00
parent 2f64909469
commit 4770ac06b5
3662 changed files with 414574 additions and 89772 deletions
+59 -21
View File
@@ -4,17 +4,15 @@ use instant::Duration;
use serde::{Deserialize, Serialize};
use session_sharing_protocol::common::{Role, Scrollback, ScrollbackBlock, SessionId};
use session_sharing_protocol::sharer::SessionSourceType;
use galaxyui::keymap::ContextPredicate;
use galaxyui::{id, AppContext};
use crate::{
channel::{Channel, ChannelState},
editor::{InteractionState, ReplicaId},
features::FeatureFlag,
};
use super::{
model::{block::SerializedBlock, terminal_model::BlockIndex},
GridType, TerminalModel,
};
use super::model::block::SerializedBlock;
use super::model::terminal_model::BlockIndex;
use super::{GridType, TerminalModel};
use crate::channel::{Channel, ChannelState};
use crate::editor::{InteractionState, ReplicaId};
use crate::features::FeatureFlag;
pub mod ai_agent;
pub mod manager;
@@ -44,6 +42,46 @@ pub const COPY_LINK_TEXT: &str = "Sharing link copied";
/// most up to date will always be sent after some delay)
const SELECTION_THROTTLE_PERIOD: Duration = Duration::from_millis(20);
/// `SessionSourceType` paired with the orchestrator `task_id` that rides
/// on the `source_task_id` sidecar.
#[derive(Debug, Clone)]
pub struct SharedSessionSource {
pub source_type: SessionSourceType,
pub source_task_id: Option<String>,
}
impl SharedSessionSource {
pub fn user(source_task_id: Option<String>) -> Self {
Self {
source_type: SessionSourceType::User,
source_task_id,
}
}
pub fn ambient_agent(task_id: Option<String>) -> Self {
Self {
source_type: SessionSourceType::AmbientAgent {
task_id: task_id.clone(),
},
source_task_id: task_id,
}
}
/// Sidecar first, then `AmbientAgent.task_id` for legacy producers.
pub fn orchestrator_task_id(&self) -> Option<&str> {
self.source_task_id.as_deref().or(match &self.source_type {
SessionSourceType::AmbientAgent { task_id } => task_id.as_deref(),
SessionSourceType::User => None,
})
}
}
impl Default for SharedSessionSource {
fn default() -> Self {
Self::user(None)
}
}
/// Whether or not a local session is also being shared.
/// Since a shared session creator is also the creator of a local session,
/// we make use of the local_tty::TerminalManager for shared session creators.
@@ -51,9 +89,8 @@ const SELECTION_THROTTLE_PERIOD: Duration = Duration::from_millis(20);
/// and a regular, purely local session.
#[derive(Debug, Clone, Default)]
pub enum IsSharedSessionCreator {
/// This session should be shared automatically once bootstrapped, using the
/// provided source type.
Yes { source_type: SessionSourceType },
/// This session should be shared automatically once bootstrapped.
Yes { source: SharedSessionSource },
#[default]
No,
}
@@ -78,9 +115,9 @@ pub enum SharedSessionStatus {
FinishedViewer,
/// We haven't yet attempted to share the session because it is not bootstrapped yet.
/// The `source_type` encodes what kind of shared session will be created once the
/// session finishes bootstrapping.
SharePendingPreBootstrap { source_type: SessionSourceType },
/// The `source` encodes what kind of shared session will be created once
/// the session finishes bootstrapping.
SharePendingPreBootstrap { source: SharedSessionSource },
/// The session is bootstrapped and we're in the process of
/// sharing the session but have not yet established the
@@ -173,11 +210,11 @@ impl SharedSessionStatus {
/// Note: currently, these options only encode the point at which
/// scrollback _starts_. We do not yet support more
/// selective scrollback (e.g. a closed range).
/// The active block is always included in scrollback for the prompt.
/// The active block is included for the prompt when it is scrollback-eligible.
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub enum SharedSessionScrollbackType {
/// Do not include any scrollback in this shared session.
/// Note the active block is still sent as part of scrollback for the prompt.
/// The active block can still be sent as part of scrollback for the prompt.
/// TODO(suraj): consider renaming this to "from active block" or encapsulating
/// this with the `FromBlock` variant with the block_index equal to the
/// active block index.
@@ -195,7 +232,7 @@ impl SharedSessionScrollbackType {
/// Note that some blocks might not actually be included in the scrollback
/// even if they were specified as part of the scrollback type.
/// For example, if the [`Self::All]` variant is used, restored blocks
/// _won't_ be included in scrollback.
/// _won't_ be included in scrollback, and neither will hidden active blocks.
fn to_scrollback(self, model: &TerminalModel) -> Scrollback {
let first_block_index = self.first_block_index(model);
let blocks = model
@@ -248,9 +285,10 @@ impl SharedSessionScrollbackType {
#[cfg(not(test))]
pub fn max_session_size(ctx: &AppContext) -> Byte {
use crate::workspaces::user_workspaces::UserWorkspaces;
use galaxyui::SingletonEntity;
use crate::workspaces::user_workspaces::UserWorkspaces;
UserWorkspaces::as_ref(ctx)
.current_team()
.and_then(|team| team.billing_metadata.tier.session_sharing_policy)
@@ -418,5 +456,5 @@ pub(crate) fn decode_scrollback(scrollback: &Scrollback) -> Vec<SerializedBlock>
}
#[cfg(test)]
#[path = "mod_test.rs"]
#[path = "mod_tests.rs"]
mod tests;