Skip to content
Merged
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
12 changes: 12 additions & 0 deletions rustcode/core/rustcode-core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -971,3 +971,15 @@ mod tests {
assert_eq!(ToolErrorKind::Deferred.as_str(), "Deferred");
}
}

/// What the frontend can do with `rustcode-ui v1` blocks (#2484).
#[derive(Debug, Clone, Copy, Default, PartialEq, Eq)]
pub enum SmartUi {
/// The client never advertised Smart UI: say nothing about it.
#[default]
Unsupported,
/// The client can run blocks, but the user has the setting off.
Off,
/// The client runs blocks.
On,
}
10 changes: 5 additions & 5 deletions rustcode/engine/src/acp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,17 +118,17 @@ const SMART_UI_CAPABILITY_VERSION: u64 = 1;

fn client_smart_ui(
capabilities: &agent_client_protocol::schema::v1::ClientCapabilities,
) -> crate::app::SmartUi {
) -> rustcode_core::SmartUi {
let version = capabilities
.meta
.as_ref()
.and_then(|meta| meta.get("rustcode"))
.and_then(|rustcode| rustcode.get("smartUi"))
.and_then(serde_json::Value::as_u64);
match version {
Some(version) if version >= SMART_UI_CAPABILITY_VERSION => crate::app::SmartUi::On,
Some(0) => crate::app::SmartUi::Off,
_ => crate::app::SmartUi::Unsupported,
Some(version) if version >= SMART_UI_CAPABILITY_VERSION => rustcode_core::SmartUi::On,
Some(0) => rustcode_core::SmartUi::Off,
_ => rustcode_core::SmartUi::Unsupported,
}
}

Expand Down Expand Up @@ -3397,7 +3397,7 @@ async fn dispatch_request(
if crate::sessions::load_session_title(&session_id).is_none()
&& crate::app::actions::wants_generated_title(&prompt_text)
{
let history = [crate::app::ChatMessage::new("user", prompt_text.clone())];
let history = [rustcode_core::ChatMessage::new("user", prompt_text.clone())];
crate::sessions::save_session_title_if_absent(&session_id, &history[..]);
let fallback = crate::sessions::session_title(&history);
let title_clients = server.clients.session(&session_id);
Expand Down
2 changes: 1 addition & 1 deletion rustcode/engine/src/acp/clients.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ pub(crate) struct ClientInfo {
/// The `rustcode-viz` level it renders (`_meta.rustcode.visualizations`).
pub(crate) visualization_level: u8,
/// `_meta.rustcode.smartUi` (#2484).
pub(crate) smart_ui: crate::app::SmartUi,
pub(crate) smart_ui: rustcode_core::SmartUi,
/// `_meta.rustcode.preview` (#2138): its sessions get `localhost_preview`.
pub(crate) preview: bool,
/// It answers desktop control.
Expand Down
8 changes: 4 additions & 4 deletions rustcode/engine/src/acp/harnesses.rs
Original file line number Diff line number Diff line change
Expand Up @@ -750,7 +750,7 @@ fn switch_origin(
/// Refuse a damaged file before changing the harness record or closing a thread.
fn handoff_history(
session_id: &str,
) -> Result<Vec<crate::app::ChatMessage>, agent_client_protocol::Error> {
) -> Result<Vec<rustcode_core::ChatMessage>, agent_client_protocol::Error> {
crate::sessions::flush_history();
let directory = crate::sessions::get_active_session_dir(session_id)
.ok_or_else(|| failure("session storage is unavailable".into()))?;
Expand Down Expand Up @@ -988,7 +988,7 @@ mod tests {
#[test]
fn handoff_preserves_an_interrupted_transcript_and_refuses_corruption() {
let id = crate::sessions::create_detached_session();
let history = vec![crate::app::ChatMessage::new("user", "Still working")];
let history = vec![rustcode_core::ChatMessage::new("user", "Still working")];
crate::sessions::save_session_history(&id, &history);
crate::sessions::flush_history();
let loaded = handoff_history(&id).unwrap();
Expand Down Expand Up @@ -1038,8 +1038,8 @@ mod tests {

// The history the load replays, with no harness started.
let history = vec![
crate::app::ChatMessage::new("user", "hello"),
crate::app::ChatMessage::new("assistant", "hi"),
rustcode_core::ChatMessage::new("user", "hello"),
rustcode_core::ChatMessage::new("assistant", "hi"),
];
let updates = harness::transcript::replay(&history, None);
assert!(updates.len() >= 2, "the recorded conversation replays");
Expand Down
2 changes: 1 addition & 1 deletion rustcode/engine/src/acp/project_relocate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ mod tests {
let history_path = crate::sessions::get_active_session_dir(&id)
.unwrap()
.join("history.json");
let history = serde_json::to_vec(&vec![crate::app::ChatMessage::new(
let history = serde_json::to_vec(&vec![rustcode_core::ChatMessage::new(
"user",
"Keep this history",
)])
Expand Down
6 changes: 3 additions & 3 deletions rustcode/engine/src/acp/session_load.rs
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ pub(super) fn acp_list_sessions(
}

pub(crate) fn replay_history_updates(
history: &[crate::app::ChatMessage],
history: &[rustcode_core::ChatMessage],
cwd: Option<&std::path::Path>,
) -> Vec<SessionUpdate> {
replay_history_updates_with_compaction(history, cwd, None)
Expand All @@ -223,7 +223,7 @@ pub(crate) fn replay_history_updates(
/// left its summary. `compaction` is the session's recorded last
/// compaction; it describes the latest summary only.
pub(super) fn replay_history_updates_with_compaction(
history: &[crate::app::ChatMessage],
history: &[rustcode_core::ChatMessage],
cwd: Option<&std::path::Path>,
compaction: Option<&crate::app::CompactionStats>,
) -> Vec<SessionUpdate> {
Expand Down Expand Up @@ -797,7 +797,7 @@ pub(crate) async fn attach_with_replay<F>(
session_id: &str,
resume: Option<u64>,
history: impl Fn() -> F,
replay: impl Fn(&[crate::app::ChatMessage]) -> Vec<SessionUpdate>,
replay: impl Fn(&[rustcode_core::ChatMessage]) -> Vec<SessionUpdate>,
) -> Result<cursor::Position, agent_client_protocol::Error>
where
F: std::future::Future<Output = rustcode_core::History>,
Expand Down
12 changes: 6 additions & 6 deletions rustcode/engine/src/acp/session_move.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ mod tests {
let (_dir, repo) = crate::worktrees::tests::repo();
let id = "acp-move-repo";
let history = vec![
crate::app::ChatMessage::new("user", "Move me"),
crate::app::ChatMessage::new("assistant", "Moved"),
rustcode_core::ChatMessage::new("user", "Move me"),
rustcode_core::ChatMessage::new("assistant", "Moved"),
];
store.ensure_session(id);
store.save_session_history(id, &history);
Expand All @@ -80,8 +80,8 @@ mod tests {
let (old, new) = (tempfile::tempdir().unwrap(), tempfile::tempdir().unwrap());
let extra = std::path::PathBuf::from("/tmp/extra");
let history = vec![
crate::app::ChatMessage::new("user", "Move me"),
crate::app::ChatMessage::new("assistant", "Moved"),
rustcode_core::ChatMessage::new("user", "Move me"),
rustcode_core::ChatMessage::new("assistant", "Moved"),
];
for id in ["acp-move-a", "acp-move-b"] {
store.save_session_history(id, &history);
Expand Down Expand Up @@ -120,8 +120,8 @@ mod tests {
store.save_session_history(
id,
&vec![
crate::app::ChatMessage::new("user", "Move me"),
crate::app::ChatMessage::new("assistant", "Moved"),
rustcode_core::ChatMessage::new("user", "Move me"),
rustcode_core::ChatMessage::new("assistant", "Moved"),
],
);
rustcode_session::flush_history();
Expand Down
4 changes: 2 additions & 2 deletions rustcode/engine/src/acp/session_repair.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@ mod tests {
store.save_session_history(
id,
&vec![
crate::app::ChatMessage::new("user", "Fix me"),
crate::app::ChatMessage::new("assistant", "Fixed"),
rustcode_core::ChatMessage::new("user", "Fix me"),
rustcode_core::ChatMessage::new("assistant", "Fixed"),
],
);
rustcode_session::flush_history();
Expand Down
2 changes: 1 addition & 1 deletion rustcode/engine/src/acp/session_transfer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ use std::path::{Path, PathBuf};
use std::sync::{Mutex, OnceLock};
use std::time::{Duration, Instant};

use crate::app::ChatMessage;
use crate::harness::{self, store as harness_store};
use crate::sessions::MachineOrigin;
use rustcode_core::ChatMessage;

/// Raw bytes per export/import chunk (384 KiB raw -> 512 KiB base64, well below
/// `remote_gateway::gateway::MAX_FRAME_BYTES` = 1 MiB).
Expand Down
Loading
Loading