fix(assistant): a change left waiting past its day no longer holds the next one back

The open changes of a thread are now the ones still inside their decision
window. A call older than a day already reads as expired in the thread and
can no longer be decided, but it stayed approval_requested until the nightly
sweep, so "+ Tour", "+ Day" and "Plan this" answered decide_first with
nothing left to decide, and a decision had to name the expired call too.
listOpen takes the window's start, and every caller passes the same cutoff.
This commit is contained in:
Maurice
2026-10-24 01:21:18 +00:00
parent a6a9f3bbdd
commit bfcc205f05
10 changed files with 100 additions and 21 deletions
@@ -145,13 +145,18 @@ export class AssistantToolCallsRepository extends TrekRepository<AssistantToolCa
.execute();
}
/** The calls of a thread still waiting for a decision. */
async listOpen(threadId: number): Promise<AssistantToolCallRow[]> {
/**
* The calls of a thread still waiting for a decision, proposed at or after
* `notBefore`: an older one has expired, as the thread shows it and as
* `claimDecision` refuses it, even before the nightly sweep marks it so.
*/
async listOpen(threadId: number, notBefore: string): Promise<AssistantToolCallRow[]> {
return this.db()
.selectFrom('assistant_tool_calls')
.select(COLUMNS)
.where('thread_id', '=', threadId)
.where('state', '=', 'approval_requested')
.where('created_at', '>=', notBefore)
.orderBy('created_at')
.orderBy('id')
.execute();