Skip to content

Commit 2a1a8a2

Browse files
TimelordUKclaude
andcommitted
feat: migrate mode and cache_mode fields to buffer system
- Add cache_mode field to Buffer struct with BufferAPI methods - Add wrapper methods is_cache_mode() and set_cache_mode() - Update all 6 cache_mode references to use wrapper methods - Add cache_mode to buffer debug output - Migrate mode field using existing wrapper methods - Update all 52+ mode references to use get_mode() and set_mode() - Replace direct assignments with set_mode() calls - Replace match/comparison statements with get_mode() calls Both fields now properly use buffer system for per-buffer state management. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent f9f1bca commit 2a1a8a2

3 files changed

Lines changed: 99 additions & 70 deletions

File tree

sql-cli/PHASE2_MIGRATION_PLAN.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ These are buffer-specific and should move:
1717
- `textarea` - Multi-line editor for this buffer
1818
- `results` - Query results for this buffer
1919
-`table_state` - Table selection state **[DONE - Wrapper added, tested, working]**
20-
- `mode` - Current mode (Command/Results/etc) for this buffer
20+
- `mode` - Current mode (Command/Results/etc) for this buffer **[DONE - Using existing wrapper methods]**
2121
-`status_message` - Status message for current buffer **[DONE - Fully migrated]**
2222

2323
#### Filtering/Search State
@@ -82,7 +82,7 @@ These are truly application-wide:
8282

8383
### 🟡 Needs Discussion
8484
These could go either way:
85-
- `cache_mode` - Could be global or per-buffer
85+
- `cache_mode` - Could be global or per-buffer **[DONE - Migrated to buffer system]**
8686
- `last_visible_rows` - Viewport tracking, probably per-buffer
8787

8888
## Migration Status

sql-cli/src/buffer.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,8 @@ pub trait BufferAPI {
215215
fn get_csv_client_mut(&mut self) -> Option<&mut CsvApiClient>;
216216
fn is_csv_mode(&self) -> bool;
217217
fn get_table_name(&self) -> String;
218+
fn is_cache_mode(&self) -> bool;
219+
fn set_cache_mode(&mut self, cache_mode: bool);
218220

219221
// --- Input State ---
220222
fn get_input_value(&self) -> String;
@@ -253,6 +255,7 @@ pub struct Buffer {
253255
pub csv_client: Option<CsvApiClient>,
254256
pub csv_mode: bool,
255257
pub csv_table_name: String,
258+
pub cache_mode: bool,
256259
pub results: Option<QueryResponse>,
257260
pub cached_data: Option<Vec<serde_json::Value>>,
258261

@@ -571,6 +574,14 @@ impl BufferAPI for Buffer {
571574
self.csv_table_name.clone()
572575
}
573576

577+
fn is_cache_mode(&self) -> bool {
578+
self.cache_mode
579+
}
580+
581+
fn set_cache_mode(&mut self, cache_mode: bool) {
582+
self.cache_mode = cache_mode;
583+
}
584+
574585
// --- Input State ---
575586
fn get_input_value(&self) -> String {
576587
self.input.value().to_string()
@@ -722,6 +733,7 @@ impl BufferAPI for Buffer {
722733
output.push_str("\n--- CSV/Data Source ---\n");
723734
output.push_str(&format!("CSV Mode: {}\n", self.csv_mode));
724735
output.push_str(&format!("CSV Table Name: '{}'\n", self.csv_table_name));
736+
output.push_str(&format!("Cache Mode: {}\n", self.cache_mode));
725737
output.push_str(&format!("Has CSV Client: {}\n", self.csv_client.is_some()));
726738
output.push_str(&format!(
727739
"Has Cached Data: {}\n",
@@ -770,6 +782,7 @@ impl Buffer {
770782
csv_client: None,
771783
csv_mode: false,
772784
csv_table_name: String::new(),
785+
cache_mode: false,
773786
results: None,
774787
cached_data: None,
775788

0 commit comments

Comments
 (0)