Refactor scrolling methods in ScrollState to accept an amount parameter
- Updated `scroll_up` and `scroll_down` methods to take an `amount` parameter for more flexible scrolling. - Removed the `AgentMode` enum and related methods from the types module to simplify state management. - Modified `AppStateRest` to remove the `mode` field and adjusted related logic. - Enhanced `run_subagent` to build tool definitions and handle API key resolution from configuration. - Updated command parsing to reflect changes in login handling. - Removed onboarding overlays and related logic from input handling and rendering. - Improved status bar to reflect connection status and agent readiness. - Adjusted workflow panel rendering to simplify phase status display. - Refactored edit log initialization to load from disk if available. - Updated settings structure to use a HashMap for API keys. - Enhanced error handling in LlmClient for authentication issues.
This commit is contained in:
@@ -35,17 +35,12 @@ impl ScrollState {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn scroll_up(&mut self) {
|
||||
if self.offset > 0 {
|
||||
self.offset -= 1;
|
||||
}
|
||||
pub fn scroll_up(&mut self, amount: usize) {
|
||||
self.offset = self.offset.saturating_add(amount);
|
||||
}
|
||||
|
||||
pub fn scroll_down(&mut self, total: usize) {
|
||||
let max_offset = total.saturating_sub(self.max_visible);
|
||||
if self.offset < max_offset {
|
||||
self.offset += 1;
|
||||
}
|
||||
pub fn scroll_down(&mut self, amount: usize) {
|
||||
self.offset = self.offset.saturating_sub(amount);
|
||||
}
|
||||
|
||||
pub fn set_max_visible(&mut self, max: usize) {
|
||||
|
||||
@@ -5,7 +5,7 @@ use tokio::sync::RwLock;
|
||||
|
||||
use super::misc::{DirCache, InputState, MiscState, ScrollState};
|
||||
use super::runtime::{SessionRuntime, TurnEvent};
|
||||
use super::types::{AgentMode, Origin, Toast, TranscriptCache};
|
||||
use super::types::{Origin, Toast, TranscriptCache};
|
||||
use crate::app::mcp::manager::McpManager;
|
||||
use crate::app::workflow::engine::WorkflowEngine;
|
||||
use crate::model::app_config::AppConfig;
|
||||
@@ -31,7 +31,7 @@ impl ChatMessageDisplay {
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct AppStateRest {
|
||||
pub mode: AgentMode,
|
||||
|
||||
pub settings: Settings,
|
||||
pub app_config: AppConfig,
|
||||
pub workspace_roots: Vec<PathBuf>,
|
||||
@@ -50,6 +50,7 @@ pub struct AppStateRest {
|
||||
pub misc: MiscState,
|
||||
pub turn_events: Arc<Mutex<VecDeque<TurnEvent>>>,
|
||||
pub turn_in_flight: Arc<Mutex<bool>>,
|
||||
pub abort_flag: Arc<std::sync::atomic::AtomicBool>,
|
||||
pub workflow_engine: WorkflowEngine,
|
||||
pub mcp_manager: McpManager,
|
||||
pub dirty: bool,
|
||||
@@ -68,7 +69,7 @@ impl AppStateRest {
|
||||
.map(|n| n.to_string_lossy().to_string())
|
||||
.unwrap_or_default();
|
||||
AppStateRest {
|
||||
mode: AgentMode::Auto,
|
||||
|
||||
settings,
|
||||
app_config,
|
||||
workspace_roots,
|
||||
@@ -79,6 +80,7 @@ impl AppStateRest {
|
||||
worktrees_dir,
|
||||
turn_events: Arc::new(Mutex::new(VecDeque::new())),
|
||||
turn_in_flight: Arc::new(Mutex::new(false)),
|
||||
abort_flag: Arc::new(std::sync::atomic::AtomicBool::new(false)),
|
||||
dir_cache: Arc::new(RwLock::new(dir_cache)),
|
||||
edit_log: EditLog::new(&session_dir),
|
||||
session_runtime: Some(SessionRuntime::new(session_dir.clone())),
|
||||
@@ -98,10 +100,7 @@ impl AppStateRest {
|
||||
self.turn_in_flight.lock().map(|g| *g).unwrap_or(false)
|
||||
}
|
||||
|
||||
pub fn set_mode(&mut self, mode: AgentMode) {
|
||||
self.mode = mode;
|
||||
self.dirty = true;
|
||||
}
|
||||
|
||||
|
||||
pub fn push_transcript(&mut self, msg: ChatMessageDisplay) {
|
||||
self.transcript_cache.messages.push(msg);
|
||||
|
||||
+1
-34
@@ -1,36 +1,5 @@
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
|
||||
pub enum AgentMode {
|
||||
Auto,
|
||||
Normal,
|
||||
Plan,
|
||||
Yolo,
|
||||
}
|
||||
|
||||
impl AgentMode {
|
||||
pub fn auto_approve(&self) -> bool {
|
||||
matches!(self, AgentMode::Auto | AgentMode::Yolo)
|
||||
}
|
||||
|
||||
pub fn name(&self) -> &'static str {
|
||||
match self {
|
||||
AgentMode::Auto => "Auto",
|
||||
AgentMode::Normal => "Normal",
|
||||
AgentMode::Plan => "Plan",
|
||||
AgentMode::Yolo => "Yolo",
|
||||
}
|
||||
}
|
||||
|
||||
pub fn cycle(&self) -> AgentMode {
|
||||
match self {
|
||||
AgentMode::Normal => AgentMode::Auto,
|
||||
AgentMode::Auto => AgentMode::Plan,
|
||||
AgentMode::Plan => AgentMode::Yolo,
|
||||
AgentMode::Yolo => AgentMode::Normal,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
|
||||
pub enum ToastKind {
|
||||
@@ -73,8 +42,7 @@ pub enum Overlay {
|
||||
Bash,
|
||||
QuitConfirm,
|
||||
Workflow,
|
||||
Onboard,
|
||||
OnboardProvider,
|
||||
|
||||
KeyInput,
|
||||
Editor,
|
||||
Effort,
|
||||
@@ -87,7 +55,6 @@ pub enum Overlay {
|
||||
Loading,
|
||||
ModelSelector,
|
||||
ClearConfirm,
|
||||
LoginPicker,
|
||||
}
|
||||
|
||||
impl Overlay {
|
||||
|
||||
Reference in New Issue
Block a user