Skip to content

Commit cf39dbc

Browse files
committed
refactor(tui): improve struct field ordering by semantic group
- ChatView: move show_thinking next to theme (config group), separate fields into config / persistent data / transient buffers / view state with inline group comments. Move MAX_TOOL_OUTPUT_LINES constant from ChatEntry section to ChatView section where it is consumed. - StatusBar: move cwd next to model (static display data), before status and spinner fields (dynamic state).
1 parent 27d74a5 commit cf39dbc

2 files changed

Lines changed: 14 additions & 8 deletions

File tree

crates/oxide-code/src/tui/components/chat.rs

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,6 @@ use crate::tui::theme::Theme;
1212

1313
// ── Chat Entry ──
1414

15-
/// Maximum lines of tool output shown inline before truncation.
16-
const MAX_TOOL_OUTPUT_LINES: usize = 5;
17-
1815
/// A single entry in the chat history.
1916
#[derive(Debug, Clone)]
2017
enum ChatEntry {
@@ -33,15 +30,24 @@ enum ChatEntry {
3330

3431
// ── Chat View ──
3532

33+
/// Maximum lines of tool output shown inline before truncation.
34+
const MAX_TOOL_OUTPUT_LINES: usize = 5;
35+
3636
/// Scrollable chat message list with markdown rendering, tool call display,
3737
/// and thinking block support.
3838
///
3939
/// Renders messages vertically with role labels and auto-scrolls to the
4040
/// bottom on new content. The user can scroll up to review history; new
4141
/// content pauses auto-scroll until the user scrolls back to the bottom.
4242
pub(crate) struct ChatView {
43+
// Config
4344
theme: Theme,
45+
show_thinking: bool,
46+
47+
// Persistent data
4448
entries: Vec<ChatEntry>,
49+
50+
// Transient buffers (cleared per turn)
4551
/// Text being streamed for the current assistant response.
4652
streaming_buffer: String,
4753
/// Rendered lines for the stable prefix of the streaming buffer.
@@ -55,13 +61,13 @@ pub(crate) struct ChatView {
5561
streaming_rendered_boundary: usize,
5662
/// Thinking tokens accumulated during extended thinking.
5763
thinking_buffer: String,
58-
show_thinking: bool,
64+
65+
// View state
5966
scroll_offset: u16,
6067
/// Total content height from the last render (for scroll bounds).
6168
/// Uses `Cell` for interior mutability so `render` (`&self`) can
6269
/// update it during the render pass without a second `build_text` call.
6370
content_height: Cell<u16>,
64-
/// Viewport height from the last render.
6571
viewport_height: u16,
6672
auto_scroll: bool,
6773
}
@@ -70,12 +76,12 @@ impl ChatView {
7076
pub(crate) fn new(theme: Theme, show_thinking: bool) -> Self {
7177
Self {
7278
theme,
79+
show_thinking,
7380
entries: Vec::new(),
7481
streaming_buffer: String::new(),
7582
streaming_rendered: Vec::new(),
7683
streaming_rendered_boundary: 0,
7784
thinking_buffer: String::new(),
78-
show_thinking,
7985
scroll_offset: 0,
8086
content_height: Cell::new(0),
8187
viewport_height: 0,

crates/oxide-code/src/tui/components/status.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ const TICKS_PER_FRAME: usize = 5;
2020
pub(crate) struct StatusBar {
2121
theme: Theme,
2222
model: String,
23-
status: Status,
2423
cwd: String,
24+
status: Status,
2525
spinner_frame: usize,
2626
tick_counter: usize,
2727
}
@@ -38,8 +38,8 @@ impl StatusBar {
3838
Self {
3939
theme,
4040
model,
41-
status: Status::Idle,
4241
cwd,
42+
status: Status::Idle,
4343
spinner_frame: 0,
4444
tick_counter: 0,
4545
}

0 commit comments

Comments
 (0)