agent: switch from tokio::sync::Mutex to std::sync::Mutex
The agent lock is never held across await points — turns lock briefly, do work, drop, then do async API calls. std::sync::Mutex works and can be locked from sync contexts (screen tick inside terminal.draw). Fixes: blocking_lock() panic when called inside tokio runtime. Co-Authored-By: Kent Overstreet <kent.overstreet@linux.dev>
This commit is contained in:
parent
f29b4be09c
commit
3e1be4d353
8 changed files with 41 additions and 39 deletions
|
|
@ -602,7 +602,7 @@ fn str_err<T>(r: Result<T, String>) -> anyhow::Result<T> {
|
|||
|
||||
/// digest_daily tool handler: generate a daily digest
|
||||
async fn handle_digest_daily(
|
||||
_agent: Option<std::sync::Arc<tokio::sync::Mutex<super::super::agent::Agent>>>,
|
||||
_agent: Option<std::sync::Arc<std::sync::Mutex<super::super::agent::Agent>>>,
|
||||
args: serde_json::Value,
|
||||
) -> anyhow::Result<String> {
|
||||
let date = str_err(get_str_required(&args, "date"))?;
|
||||
|
|
@ -613,7 +613,7 @@ async fn handle_digest_daily(
|
|||
|
||||
/// digest_weekly tool handler: generate a weekly digest
|
||||
async fn handle_digest_weekly(
|
||||
_agent: Option<std::sync::Arc<tokio::sync::Mutex<super::super::agent::Agent>>>,
|
||||
_agent: Option<std::sync::Arc<std::sync::Mutex<super::super::agent::Agent>>>,
|
||||
args: serde_json::Value,
|
||||
) -> anyhow::Result<String> {
|
||||
let week_label = str_err(get_str_required(&args, "week"))?;
|
||||
|
|
@ -624,7 +624,7 @@ async fn handle_digest_weekly(
|
|||
|
||||
/// digest_monthly tool handler: generate a monthly digest
|
||||
async fn handle_digest_monthly(
|
||||
_agent: Option<std::sync::Arc<tokio::sync::Mutex<super::super::agent::Agent>>>,
|
||||
_agent: Option<std::sync::Arc<std::sync::Mutex<super::super::agent::Agent>>>,
|
||||
args: serde_json::Value,
|
||||
) -> anyhow::Result<String> {
|
||||
let month = str_err(get_str_required(&args, "month"))?;
|
||||
|
|
@ -635,7 +635,7 @@ async fn handle_digest_monthly(
|
|||
|
||||
/// digest_auto tool handler: auto-generate all missing digests
|
||||
async fn handle_digest_auto(
|
||||
_agent: Option<std::sync::Arc<tokio::sync::Mutex<super::super::agent::Agent>>>,
|
||||
_agent: Option<std::sync::Arc<std::sync::Mutex<super::super::agent::Agent>>>,
|
||||
_args: serde_json::Value,
|
||||
) -> anyhow::Result<String> {
|
||||
let mut store = str_err(Store::load())?;
|
||||
|
|
@ -645,7 +645,7 @@ async fn handle_digest_auto(
|
|||
|
||||
/// digest_links tool handler: parse and apply digest links
|
||||
async fn handle_digest_links(
|
||||
_agent: Option<std::sync::Arc<tokio::sync::Mutex<super::super::agent::Agent>>>,
|
||||
_agent: Option<std::sync::Arc<std::sync::Mutex<super::super::agent::Agent>>>,
|
||||
_args: serde_json::Value,
|
||||
) -> anyhow::Result<String> {
|
||||
let mut store = str_err(Store::load())?;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue