Implement chat and markdown views, enhance status bar, and add workflow panel

- Added `chat.rs` for rendering chat messages with timestamps and roles.
- Introduced `markdown.rs` for rendering markdown content with styling.
- Created `status.rs` to display the application status bar with session and message counts.
- Developed `workflow.rs` to show the current workflow status, including tool calls and active jobs.
- Established a `theme.rs` for centralized color management across the UI.
- Updated `mod.rs` to include new modules and manage rendering logic.
This commit is contained in:
asepharyana
2026-07-11 13:16:10 +07:00
parent 7cb4ae6708
commit cc03bd79b6
131 changed files with 10994 additions and 0 deletions
+44
View File
@@ -0,0 +1,44 @@
use std::io::{Read, Write};
use anyhow::Result;
pub(crate) const MAX_FRAME_SIZE: usize = 64 * 1024 * 1024;
pub fn write_frame<W: Write>(writer: &mut W, data: &[u8]) -> Result<()> {
let len = data.len();
if len > MAX_FRAME_SIZE {
anyhow::bail!("frame too large: {} bytes exceeds 64 MiB limit", len);
}
let len_bytes = (len as u32).to_be_bytes();
writer.write_all(&len_bytes)?;
writer.write_all(data)?;
writer.flush()?;
Ok(())
}
pub fn read_frame<R: Read>(reader: &mut R) -> Result<Option<Vec<u8>>> {
let mut len_buf = [0u8; 4];
match reader.read_exact(&mut len_buf) {
Ok(()) => {}
Err(e) if e.kind() == std::io::ErrorKind::UnexpectedEof => return Ok(None),
Err(e) => return Err(e.into()),
}
let len = u32::from_be_bytes(len_buf) as usize;
if len > MAX_FRAME_SIZE {
anyhow::bail!("frame too large: {} bytes exceeds 64 MiB limit", len);
}
let mut buf = vec![0u8; len];
reader.read_exact(&mut buf)?;
Ok(Some(buf))
}
pub fn serialize_frame<T: serde::Serialize>(value: &T) -> Result<Vec<u8>> {
let json = serde_json::to_vec(value)?;
if json.len() > MAX_FRAME_SIZE {
anyhow::bail!("serialized frame too large: {} bytes", json.len());
}
Ok(json)
}
pub fn deserialize_frame<'a, T: serde::Deserialize<'a>>(data: &'a [u8]) -> Result<T> {
Ok(serde_json::from_slice(data)?)
}