Skip to content

Commit

Permalink
Add streaming_diff crate (#23264)
Browse files Browse the repository at this point in the history
This PR extracts the streaming diff implementation to its own
`streaming_diff` crate.

It was duplicated between `assistant` and `assistant2`, but their
implementations were exactly the same (and I don't see a reason why they
would need to diverge).

Release Notes:

- N/A
  • Loading branch information
maxdeviant authored Jan 16, 2025
1 parent 4d22f7e commit 24495f0
Show file tree
Hide file tree
Showing 12 changed files with 41 additions and 1,113 deletions.
14 changes: 12 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ members = [
"crates/sqlez_macros",
"crates/story",
"crates/storybook",
"crates/streaming_diff",
"crates/sum_tree",
"crates/supermaven",
"crates/supermaven_api",
Expand Down Expand Up @@ -307,6 +308,7 @@ sqlez = { path = "crates/sqlez" }
sqlez_macros = { path = "crates/sqlez_macros" }
story = { path = "crates/story" }
storybook = { path = "crates/storybook" }
streaming_diff = { path = "crates/streaming_diff" }
sum_tree = { path = "crates/sum_tree" }
supermaven = { path = "crates/supermaven" }
supermaven_api = { path = "crates/supermaven_api" }
Expand Down
2 changes: 1 addition & 1 deletion crates/assistant/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ lsp.workspace = true
menu.workspace = true
multi_buffer.workspace = true
open_ai = { workspace = true, features = ["schemars"] }
ordered-float.workspace = true
parking_lot.workspace = true
paths.workspace = true
picker.workspace = true
Expand All @@ -71,6 +70,7 @@ settings.workspace = true
similar.workspace = true
smallvec.workspace = true
smol.workspace = true
streaming_diff.workspace = true
strum.workspace = true
telemetry.workspace = true
telemetry_events.workspace = true
Expand Down
2 changes: 0 additions & 2 deletions crates/assistant/src/assistant.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ mod prompt_library;
mod slash_command;
pub(crate) mod slash_command_picker;
pub mod slash_command_settings;
mod streaming_diff;
mod terminal_inline_assistant;

use std::path::PathBuf;
Expand Down Expand Up @@ -39,7 +38,6 @@ pub use crate::context_store::*;
pub(crate) use crate::inline_assistant::*;
pub use crate::patch::*;
use crate::slash_command_settings::SlashCommandSettings;
pub(crate) use crate::streaming_diff::*;

actions!(
assistant,
Expand Down
6 changes: 3 additions & 3 deletions crates/assistant/src/inline_assistant.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use crate::{
humanize_token_count, AssistantPanel, AssistantPanelEvent, CharOperation,
CycleNextInlineAssist, CyclePreviousInlineAssist, LineDiff, LineOperation, RequestType,
StreamingDiff,
humanize_token_count, AssistantPanel, AssistantPanelEvent, CycleNextInlineAssist,
CyclePreviousInlineAssist, RequestType,
};
use anyhow::{anyhow, Context as _, Result};
use assistant_settings::AssistantSettings;
Expand Down Expand Up @@ -56,6 +55,7 @@ use std::{
task::{self, Poll},
time::{Duration, Instant},
};
use streaming_diff::{CharOperation, LineDiff, LineOperation, StreamingDiff};
use telemetry_events::{AssistantEvent, AssistantKind, AssistantPhase};
use terminal_view::terminal_panel::TerminalPanel;
use text::{OffsetRangeExt, ToPoint as _};
Expand Down
2 changes: 1 addition & 1 deletion crates/assistant2/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ lsp.workspace = true
markdown.workspace = true
menu.workspace = true
multi_buffer.workspace = true
ordered-float.workspace = true
parking_lot.workspace = true
picker.workspace = true
project.workspace = true
Expand All @@ -55,6 +54,7 @@ serde_json.workspace = true
settings.workspace = true
similar.workspace = true
smol.workspace = true
streaming_diff.workspace = true
telemetry_events.workspace = true
terminal.workspace = true
terminal_view.workspace = true
Expand Down
1 change: 0 additions & 1 deletion crates/assistant2/src/assistant.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ mod context_strip;
mod inline_assistant;
mod inline_prompt_editor;
mod message_editor;
mod streaming_diff;
mod terminal_codegen;
mod terminal_inline_assistant;
mod thread;
Expand Down
2 changes: 1 addition & 1 deletion crates/assistant2/src/buffer_codegen.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use crate::context::attach_context_to_message;
use crate::context_store::ContextStore;
use crate::inline_prompt_editor::CodegenStatus;
use crate::streaming_diff::{CharOperation, LineDiff, LineOperation, StreamingDiff};
use anyhow::{Context as _, Result};
use client::telemetry::Telemetry;
use collections::HashSet;
Expand Down Expand Up @@ -29,6 +28,7 @@ use std::{
task::{self, Poll},
time::Instant,
};
use streaming_diff::{CharOperation, LineDiff, LineOperation, StreamingDiff};
use telemetry_events::{AssistantEvent, AssistantKind, AssistantPhase};

pub struct BufferCodegen {
Expand Down
Loading

0 comments on commit 24495f0

Please sign in to comment.