fix: fixed git handling

This commit is contained in:
Georg Bauer
2026-07-28 21:11:46 +02:00
parent 9b5b3a2f6a
commit dbccaf7088
6 changed files with 86 additions and 51 deletions

View File

@@ -441,13 +441,13 @@ impl App {
if self.selected_project.is_none() {
return;
}
let prompt = self.composer.trim().to_owned();
let prompt = self.composer.text().trim().to_owned();
if prompt.is_empty() {
return;
}
#[cfg(target_os = "macos")]
if prompt == "/compact" {
self.composer.clear();
self.composer = text_editor::Content::new();
if self.generating {
self.manual_compaction_queued = true;
self.activity = Some("Compaction queued for the next safe point…".into());
@@ -460,7 +460,7 @@ impl App {
}
if self.generating {
self.queued_inputs.push_back(prompt);
self.composer.clear();
self.composer = text_editor::Content::new();
self.activity = Some(format!(
"{} queued input{}",
self.queued_inputs.len(),
@@ -689,7 +689,7 @@ impl App {
self.conversation.push(ChatMessage::from(message));
}
assistant.reasoning_open = assistant_reasoning;
self.composer.clear();
self.composer = text_editor::Content::new();
self.conversation.push(user);
self.conversation.push(assistant);
self.generating = true;
@@ -1167,7 +1167,7 @@ impl App {
}
if let Some(prompt) = queued_prompt(self.queued_inputs.drain(..)) {
self.finish_turn_summary();
self.composer = prompt;
self.composer = text_editor::Content::with_text(&prompt);
self.start_generation();
}
}
@@ -1588,7 +1588,7 @@ impl App {
match request.pending {
PendingContinuation::None => self.start_next_queued(),
PendingContinuation::User(prompt) => {
self.composer = prompt;
self.composer = text_editor::Content::with_text(&prompt);
self.skip_compaction_once = true;
self.start_generation();
}
@@ -1608,8 +1608,8 @@ impl App {
Err(error) => {
self.generating = false;
if let PendingContinuation::User(prompt) = request.pending {
if self.composer.trim().is_empty() {
self.composer = prompt;
if self.composer.text().trim().is_empty() {
self.composer = text_editor::Content::with_text(&prompt);
} else {
self.queued_inputs.push_front(prompt);
}

View File

@@ -175,7 +175,7 @@ impl App {
self.chat_follow_tail = true;
self.context_notice = None;
self.clear_a2ui();
self.composer.clear();
self.composer = text_editor::Content::new();
self.queued_inputs.clear();
self.system_prompt_seen_at = 0;
self.context_used = 0;
@@ -190,7 +190,7 @@ impl App {
self.chat_follow_tail = true;
self.context_notice = None;
self.clear_a2ui();
self.composer.clear();
self.composer = text_editor::Content::new();
self.queued_inputs.clear();
self.system_prompt_seen_at = 0;
self.context_used = 0;

View File

@@ -1012,6 +1012,14 @@ fn danger_button_style(theme: &Theme, status: button::Status) -> button::Style {
style
}
fn stop_button_style(theme: &Theme, status: button::Status) -> button::Style {
let mut style = action_button_style(theme, status);
if matches!(status, button::Status::Hovered | button::Status::Pressed) {
style.text_color = theme.palette().danger;
}
style
}
fn segmented_control_style(_: &Theme) -> container::Style {
container::Style {
background: Some(Background::Color(Color::from_rgb8(24, 24, 26))),

View File

@@ -217,38 +217,36 @@ impl App {
// left behind an open dialog would take a turn in that dialog's
// field order. Behind a modal it becomes a plain look-alike that
// cannot be focused; the modal dims it either way.
let composer: Element<'_, Message> = if self.modal_open() {
container(
text(if self.composer.is_empty() {
"Ask DS4Server anything…"
} else {
&self.composer
})
.size(14)
.color(muted_text()),
)
.padding(12)
.width(Length::Fill)
.into()
} else {
text_input(
if self.generating {
"Add guidance to the queue…"
} else {
"Ask DS4Server anything…"
},
&self.composer,
)
.id(composer_id())
.on_input(Message::ComposerChanged)
.on_submit(Message::SubmitPrompt)
let composer = text_editor(&self.composer)
.placeholder(if self.generating {
"Add guidance to the queue…"
} else {
"Ask DS4Server anything…"
})
.height(Length::Shrink)
.max_height(160)
.padding(12)
.size(14)
.into()
.wrapping(iced::widget::text::Wrapping::Word)
.style(selectable_text_style);
let composer: Element<'_, Message> = if self.modal_open() {
composer.into()
} else {
composer
.id(composer_id())
.on_action(Message::ComposerAction)
.key_binding(|event| {
composer_enter_binding(&event.key, event.modifiers)
.or_else(|| text_editor::Binding::from_key_press(event))
})
.into()
};
let action = if self.generating {
action_button(text("Stop").size(12)).on_press(Message::StopGeneration)
} else if self.composer.trim().is_empty() {
action_button(text("").size(13))
.padding(8)
.style(stop_button_style)
.on_press(Message::StopGeneration)
} else if self.composer.text().trim().is_empty() {
action_button(icon(ICON_SEND, 18)).padding(8)
} else {
action_button(icon(ICON_SEND, 18))
@@ -370,7 +368,7 @@ impl App {
container(composer_content,)
.padding(16)
.width(Length::Fill)
.style(overview_style),
.style(preference_group_style),
]
.height(Length::Fill)
.spacing(8);
@@ -407,6 +405,21 @@ impl App {
}
}
fn composer_enter_binding(
key: &iced::keyboard::Key,
modifiers: iced::keyboard::Modifiers,
) -> Option<text_editor::Binding<Message>> {
match key.as_ref() {
iced::keyboard::Key::Named(iced::keyboard::key::Named::Enter) if modifiers.shift() => {
Some(text_editor::Binding::Enter)
}
iced::keyboard::Key::Named(iced::keyboard::key::Named::Enter) => {
Some(text_editor::Binding::Custom(Message::SubmitPrompt))
}
_ => None,
}
}
fn selectable_text_style(
theme: &Theme,
_status: iced::widget::text_editor::Status,
@@ -532,7 +545,7 @@ fn tool_cards(cards: Vec<crate::agent::ToolCard>) -> Element<'static, Message> {
#[cfg(test)]
mod tests {
use super::format_token_count;
use super::*;
#[test]
fn chat_divider_groups_token_counts_by_thousands() {
@@ -541,4 +554,17 @@ mod tests {
assert_eq!(format_token_count(1_000), "1,000");
assert_eq!(format_token_count(12_345_678), "12,345,678");
}
#[test]
fn composer_uses_shift_enter_for_line_breaks() {
let enter = iced::keyboard::Key::Named(iced::keyboard::key::Named::Enter);
assert!(matches!(
composer_enter_binding(&enter, iced::keyboard::Modifiers::SHIFT),
Some(text_editor::Binding::Enter)
));
assert!(matches!(
composer_enter_binding(&enter, iced::keyboard::Modifiers::empty()),
Some(text_editor::Binding::Custom(Message::SubmitPrompt))
));
}
}

View File

@@ -400,6 +400,7 @@ fn diff_half(line: Option<&GitDiffLine>, old: bool) -> Element<'static, Message>
line.map_or_else(
|| {
container(Space::new().width(Length::Fill))
.height(24)
.width(Length::Fill)
.into()
},