Skip to content
Open
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,9 @@ impl RequestFileEditsExecutor {
return ActionExecution::InvalidAction;
};

// TODO(surface-agnostic-file-edit-execution): non-GUI surfaces (e.g. the TUI) have no
// CodeDiffView, so file-edit tool calls are not executable here yet. The stacked
// surface-agnostic refactor routes execution through a shared PersistDiffModel instead.
let Some(diff_view) = self.diff_views.get(id) else {
log::warn!("Tried to execute a RequestFileEdits action without a diff view");
return ActionExecution::NotReady;
Expand Down
7 changes: 3 additions & 4 deletions app/src/ai/blocklist/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,13 @@ pub(crate) mod codebase_index_speedbump_banner;
pub(crate) mod telemetry_banner;
pub(super) mod view_util;

pub use action_model::BlocklistAIActionModel;
#[cfg_attr(target_family = "wasm", allow(unused_imports))]
pub(crate) use action_model::{
apply_edits, read_local_file_context, BlocklistAIActionEvent, FileReadResult,
ReadFileContextResult, RequestFileEditsFormatKind, ShellCommandExecutor,
ShellCommandExecutorEvent, StartAgentExecutor, StartAgentExecutorEvent, StartAgentRequest,
StartAgentRequestId,
ReadFileContextResult, RequestFileEditsFormatKind, StartAgentExecutor, StartAgentExecutorEvent,
StartAgentRequest, StartAgentRequestId,
};
pub use action_model::{BlocklistAIActionModel, ShellCommandExecutor, ShellCommandExecutorEvent};
#[cfg(any(test, feature = "integration_tests"))]
pub(crate) use block::model::testing::FakeAIBlockModel;
pub(crate) use block::{init, model, AIBlock, AIBlockEvent, RequestedEditResolution};
Expand Down
7 changes: 5 additions & 2 deletions app/src/tui_export.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@ pub use crate::ai::agent::api::ServerConversationToken;
pub use crate::ai::agent::conversation::{
AIConversationAutoexecuteMode, AIConversationId, ConversationStatus,
};
pub use crate::ai::agent::task::TaskId;
pub use crate::ai::agent::{
AIAgentExchangeId, AIAgentInput, AIAgentOutput, AIAgentOutputMessage, AIAgentOutputMessageType,
AIAgentAction, AIAgentActionId, AIAgentActionType, AIAgentExchangeId, AIAgentInput,
AIAgentOutput, AIAgentOutputMessage, AIAgentOutputMessageType, AIAgentPtyWriteMode,
AIAgentText, AIAgentTextSection, MessageId, ServerOutputId, Shared, UserQueryMode,
};
pub use crate::ai::blocklist::agent_view::{
Expand All @@ -24,6 +26,7 @@ pub use crate::ai::blocklist::history_model::{
};
pub use crate::ai::blocklist::{
BlocklistAIActionModel, BlocklistAIContextModel, BlocklistAIController, BlocklistAIInputModel,
ShellCommandExecutor, ShellCommandExecutorEvent,
};
pub use crate::ai::get_relevant_files::controller::GetRelevantFilesController;
pub use crate::ai::llms::LLMId;
Expand All @@ -36,7 +39,7 @@ pub use crate::terminal::local_tty::{
TerminalManager as LocalTtyTerminalManager, TerminalManagerInit, TerminalSurfaceInit,
TerminalSurfaceResult,
};
pub use crate::terminal::model::block::{Block, BlockId};
pub use crate::terminal::model::block::{AgentInteractionMetadata, Block, BlockId};
pub use crate::terminal::model::blockgrid::BlockGrid;
pub use crate::terminal::model::blocks::{
BlockHeight, BlockHeightItem, BlockHeightSummary, BlockList, RichContentItem, TotalIndex,
Expand Down
66 changes: 53 additions & 13 deletions crates/warp_tui/src/agent_block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
use std::rc::Rc;

use warp::tui_export::{
AIAgentExchangeId, AIAgentTextSection, AIBlockModel, AIConversationId, Appearance,
AIAgentAction, AIAgentExchangeId, AIAgentOutputMessageType, AIAgentTextSection, AIBlockModel,
AIConversationId, Appearance,
};
use warp_core::ui::color::blend::Blend;
// `ThemeFill` is the theme-layer color (it supports blend/opacity); `Fill` below
Expand All @@ -19,11 +20,13 @@ use warpui_core::{AppContext, Entity, EntityIdMap, TuiView};

const INPUT_PREFIX: &str = "≫ ";

/// Renderable pieces of an agent block; this will grow as we add tool calls and other sub-elements.
/// Renderable pieces of an agent block; this will grow as we render richer sections.
#[derive(Clone, Debug, Eq, PartialEq)]
enum TuiAIBlockSection {
Input(String),
PlainText(String),
/// A lightweight status row standing in for an agent tool call.
ToolCall(Box<AIAgentAction>),
}

/// A thin TUI rich-content view adapter backed by one agent exchange.
Expand Down Expand Up @@ -103,19 +106,41 @@ impl TuiAIBlock {
sections.push(TuiAIBlockSection::Input(input));
}

// Walk output messages in order so tool-call rows interleave with text.
if let Some(output) = self.model.status(app).output_to_render() {
let output = output.get();
sections.extend(output.text_from_agent_output().flat_map(|text| {
text.sections.iter().filter_map(|section| match section {
AIAgentTextSection::PlainText { text } => (!text.text().is_empty())
.then(|| TuiAIBlockSection::PlainText(text.text().to_owned())),
// Add item variants here as the TUI learns to render richer sections.
AIAgentTextSection::Code { .. }
| AIAgentTextSection::Table { .. }
| AIAgentTextSection::Image { .. }
| AIAgentTextSection::MermaidDiagram { .. } => None,
})
}));
for message in &output.messages {
match &message.message {
AIAgentOutputMessageType::Text(text) => {
sections.extend(text.sections.iter().filter_map(|section| {
match section {
AIAgentTextSection::PlainText { text } => (!text.text().is_empty())
.then(|| TuiAIBlockSection::PlainText(text.text().to_owned())),
// Add item variants here as the TUI learns to render richer sections.
AIAgentTextSection::Code { .. }
| AIAgentTextSection::Table { .. }
| AIAgentTextSection::Image { .. }
| AIAgentTextSection::MermaidDiagram { .. } => None,
}
}));
}
AIAgentOutputMessageType::Action(action) => {
sections.push(TuiAIBlockSection::ToolCall(Box::new(action.clone())));
}
AIAgentOutputMessageType::Reasoning { .. }
| AIAgentOutputMessageType::Summarization { .. }
| AIAgentOutputMessageType::Subagent(_)
| AIAgentOutputMessageType::TodoOperation(_)
| AIAgentOutputMessageType::WebSearch(_)
| AIAgentOutputMessageType::WebFetch(_)
| AIAgentOutputMessageType::CommentsAddressed { .. }
| AIAgentOutputMessageType::DebugOutput { .. }
| AIAgentOutputMessageType::ArtifactCreated(_)
| AIAgentOutputMessageType::SkillInvoked(_)
| AIAgentOutputMessageType::MessagesReceivedFromAgents { .. }
| AIAgentOutputMessageType::EventsFromAgents { .. } => {}
}
}
}

sections
Expand Down Expand Up @@ -191,6 +216,21 @@ impl TuiAIBlockSection {
.with_padding_top(top_padding)
.finish()
}
Self::ToolCall(_action) => {
// TODO: add richer rendering for each tool call type. This is just a rendering stub to build off of.
let text_color =
Fill::from(ThemeFill::from(theme.terminal_colors().bright.black)).into();
Box::new(
TuiContainer::new(

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can we use .finish() here?

TuiText::new("executed a tool call").with_style(
TuiStyle::default()
.fg(text_color)
.add_modifier(Modifier::DIM),
),
)
.with_padding_top(top_padding),
)
}
}
}
}
Expand Down
Loading
Loading