feat(ui): add configurable role label display and syntax highlighting support
- Introduce `RoleLabelDisplay` enum (inline, above, none) and integrate it into UI rendering and message formatting. - Replace `show_role_labels` boolean with `role_label_mode` across config, formatter, session, and TUI components. - Add `syntax_highlighting` boolean to UI settings with default `false` and support in message rendering. - Update configuration schema version to 1.3.0 and provide deserialization handling for legacy boolean values. - Extend theme definitions with code block styling fields (background, border, text, keyword, string, comment) and default values in `Theme`. - Adjust related modules (`formatting.rs`, `ui.rs`, `session.rs`, `chat_app.rs`) to use the new settings and theme fields.
This commit is contained in:
@@ -16,7 +16,7 @@ use crate::storage::{SessionMeta, StorageManager};
|
||||
use crate::types::{
|
||||
ChatParameters, ChatRequest, ChatResponse, Conversation, Message, ModelInfo, ToolCall,
|
||||
};
|
||||
use crate::ui::UiController;
|
||||
use crate::ui::{RoleLabelDisplay, UiController};
|
||||
use crate::validation::{SchemaValidator, get_builtin_schemas};
|
||||
use crate::{ChatStream, Provider};
|
||||
use crate::{
|
||||
@@ -264,7 +264,7 @@ impl SessionController {
|
||||
);
|
||||
let formatter = MessageFormatter::new(
|
||||
config_guard.ui.wrap_column as usize,
|
||||
config_guard.ui.show_role_labels,
|
||||
config_guard.ui.role_label_mode,
|
||||
)
|
||||
.with_preserve_empty(config_guard.ui.word_wrap);
|
||||
let input_buffer = InputBuffer::new(
|
||||
@@ -351,6 +351,10 @@ impl SessionController {
|
||||
self.formatter.set_wrap_width(width);
|
||||
}
|
||||
|
||||
pub fn set_role_label_mode(&mut self, mode: RoleLabelDisplay) {
|
||||
self.formatter.set_role_label_mode(mode);
|
||||
}
|
||||
|
||||
// Asynchronous access to the configuration (used internally).
|
||||
pub async fn config_async(&self) -> tokio::sync::MutexGuard<'_, Config> {
|
||||
self.config.lock().await
|
||||
|
||||
Reference in New Issue
Block a user