revise bulk-clear to explicit ids per mara's feedback, fix clippy line count

This commit is contained in:
damocles 2026-08-02 15:29:21 +02:00 committed by mara
commit bc69ee3b8f
7 changed files with 228 additions and 181 deletions

View file

@ -24,18 +24,18 @@ mod args;
mod render;
pub use args::{
AckTodosUntilArgs, AckUntilArgs, AgentGetLooseEndsArgs, AnswerArgs, AskArgs,
CancelLooseEndArgs, CancelScheduleArgs, CreateRepoArgs, EditScheduleArgs,
FireScheduleNowArgs, GetAgentMetaArgs, GetHostJournalArgs, GetLogsArgs, KillArgs, RecvArgs,
RemindArgs, RequestInitConfigArgs, RequestSchedulePromptArgs, RestartArgs, SendArgs,
SetStatusArgs, StartArgs, UpdateArgs, UpdateMetaInputsArgs,
AckUntilArgs, AgentGetLooseEndsArgs, AnswerArgs, AskArgs, CancelLooseEndArgs,
CancelScheduleArgs, CreateRepoArgs, EditScheduleArgs, FireScheduleNowArgs, GetAgentMetaArgs,
GetHostJournalArgs, GetLogsArgs, KillArgs, MarkTodosDoneArgs, RecvArgs, RemindArgs,
RequestInitConfigArgs, RequestSchedulePromptArgs, RestartArgs, SendArgs, SetStatusArgs,
StartArgs, UpdateArgs, UpdateMetaInputsArgs,
};
pub use render::{annotate_retries, format_ack, format_agent_meta, format_recv};
use render::{
dial_agent_socket, format_matrix_summary, local_questions, local_reminders, local_todos,
loose_end_kind_label, mark_local_todo_done, mark_local_todos_done_until,
matrix_unread_summary, parse_loose_end_kind, render_loose_ends, reply_err,
loose_end_kind_label, mark_local_todo_done, mark_local_todos_done, matrix_unread_summary,
parse_loose_end_kind, render_loose_ends, reply_err,
};
/// Write (or remove) the status file in the agent's own `state/` directory.
@ -349,9 +349,9 @@ impl AgentServer {
the relevant context. Each `question` or `reminder` row can be cancelled by \
passing its id + kind to `cancel_loose_end`. Empty result is reported clearly. \
Todos are capped at 40 rendered rows (newest first) so a large backlog never makes \
this call fail a trailer line reports how many more are pending and suggests an \
`ack_todos_until` value to bulk-clear the rest in one call instead of triaging \
hundreds of ids individually.\n\
this call fail a trailer line reports how many more are pending; review the shown \
batch, clear reviewed ids with `mark_todos_done`, then call again for the next batch \
instead of triaging hundreds of ids one `cancel_loose_end` at a time.\n\
Pass `agent: \"<name>\"` to inspect a specific peer agent's threads. Direct \
child agents are always accessible. For non-children, the `query_agent_state` \
capability is required without it the request is rejected with an error."
@ -552,27 +552,30 @@ impl AgentServer {
}
#[tool(
description = "Bulk-clear local todos (loose-ends v2 — bash-task completions, matrix \
unread, forge activity): every pending todo with `id <= up_to` is acked in one call, \
same shape as `ack_until` for the message inbox. Use this when `get_loose_ends` \
reports more todos than it renders individually (its truncation summary suggests a \
value) or whenever a backlog has piled up past the point of clearing ids one at a \
time note the highest id you've actually triaged, or take the suggested value \
verbatim to clear the whole shown-as-hidden tail. Only affects YOUR todos; ids above \
`up_to` stay pending. Returns how many were newly acked."
description = "Bulk-clear specific local todos (loose-ends v2 — bash-task completions, \
matrix unread, forge activity) by id in one call, instead of `cancel_loose_end`ing \
each one individually. Deliberately list-based, not range-based: pass exactly the ids \
you've actually looked at (typically the ones `get_loose_ends` just rendered) there \
is no `ack_until`-style 'clear everything below id N' shortcut for todos, since unlike \
the sequentially-read message inbox, todos are heterogeneous unrelated items and a \
blind range-clear risks silently acking something you never saw. When \
`get_loose_ends` reports more todos than it renders (its truncation trailer says so), \
review the shown batch, clear the reviewed ids here, then call `get_loose_ends` again \
for the next batch. Unknown/already-acked ids are silently skipped. Returns how many \
were newly acked."
)]
async fn ack_todos_until(&self, Parameters(args): Parameters<AckTodosUntilArgs>) -> String {
async fn mark_todos_done(&self, Parameters(args): Parameters<MarkTodosDoneArgs>) -> String {
let log = format!("{args:?}");
run_tool_envelope("ack_todos_until", log, async move {
match mark_local_todos_done_until(args.up_to).await {
run_tool_envelope("mark_todos_done", log, async move {
match mark_local_todos_done(args.ids).await {
Some(hive_agent_sock::Response::Acked { count }) => {
format!("acked {count} todo(s) up to id {}", args.up_to)
format!("acked {count} todo(s)")
}
Some(hive_agent_sock::Response::Err { message }) => {
format!("ack_todos_until failed: {message}")
format!("mark_todos_done failed: {message}")
}
Some(other) => format!("ack_todos_until unexpected response: {other:?}"),
None => "ack_todos_until: local todo socket unavailable \
Some(other) => format!("mark_todos_done unexpected response: {other:?}"),
None => "mark_todos_done: local todo socket unavailable \
(HIVE_AGENT_SOCKET unset or harness unreachable)"
.to_owned(),
}