fix: fixed git handling
This commit is contained in:
@@ -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))
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user