refactor: surface silent fallbacks with eprintln! logging
Add eprintln! logging before fallback values in 7 files where errors were previously swallowed without visibility: - [stream] malformed JSON chunk, missing usage tokens, missing tool call index - [mcp] missing result fields, client builder failure, response body read error - [subagent] missing API key in settings, all resolution paths exhausted - [state] memory_dir no-parent, session_id missing, lock poisoned, store_base_dir - [input] missing default_model for provider - [session] corrupt agents.json parse failure - [pkce] clock-before-epoch on random byte generation All fallback values are preserved — this adds observability without changing behavior for callers. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.8
parent
bb621fdff2
commit
e29dfadaa7
+25
-7
@@ -61,13 +61,22 @@ impl AppStateRest {
|
||||
pub fn new(workspace_roots: Vec<PathBuf>, session_dir: PathBuf, memory_dir: PathBuf) -> Self {
|
||||
let settings = Settings::load();
|
||||
let app_config = AppConfig::load();
|
||||
let download_dir = memory_dir.parent().unwrap_or(&memory_dir).join("downloads");
|
||||
let worktrees_dir = memory_dir.parent().unwrap_or(&memory_dir).join("worktrees");
|
||||
let download_dir = memory_dir.parent().unwrap_or_else(|| {
|
||||
eprintln!("[state] memory_dir '{}' has no parent, using it for downloads", memory_dir.display());
|
||||
&memory_dir
|
||||
}).join("downloads");
|
||||
let worktrees_dir = memory_dir.parent().unwrap_or_else(|| {
|
||||
eprintln!("[state] memory_dir '{}' has no parent, using it for worktrees", memory_dir.display());
|
||||
&memory_dir
|
||||
}).join("worktrees");
|
||||
let dir_cache = DirCache::new();
|
||||
let session_id = session_dir
|
||||
.file_name()
|
||||
.map(|n| n.to_string_lossy().to_string())
|
||||
.unwrap_or_default();
|
||||
.unwrap_or_else(|| {
|
||||
eprintln!("[state] session_dir has no file_name component, using empty session_id");
|
||||
String::new()
|
||||
});
|
||||
AppStateRest {
|
||||
|
||||
settings,
|
||||
@@ -97,7 +106,10 @@ impl AppStateRest {
|
||||
}
|
||||
|
||||
pub fn turn_in_flight(&self) -> bool {
|
||||
self.turn_in_flight.lock().map(|g| *g).unwrap_or(false)
|
||||
self.turn_in_flight.lock().map(|g| *g).unwrap_or_else(|_| {
|
||||
eprintln!("[state] turn_in_flight mutex poisoned");
|
||||
false
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -120,9 +132,15 @@ impl AppStateRest {
|
||||
self.session_dir.parent()
|
||||
.and_then(|p| p.parent())
|
||||
.map(|p| p.to_path_buf())
|
||||
.unwrap_or_else(|| self.session_dir.parent()
|
||||
.map(|p| p.to_path_buf())
|
||||
.unwrap_or_else(|| self.session_dir.clone()))
|
||||
.unwrap_or_else(|| {
|
||||
eprintln!("[state] session_dir '{}' has no grandparent, using parent", self.session_dir.display());
|
||||
self.session_dir.parent()
|
||||
.map(|p| p.to_path_buf())
|
||||
.unwrap_or_else(|| {
|
||||
eprintln!("[state] session_dir '{}' has no parent at all, using itself", self.session_dir.display());
|
||||
self.session_dir.clone()
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
pub fn tool_ctx(&self) -> crate::tool::ToolCtx {
|
||||
|
||||
Reference in New Issue
Block a user