feat: enhance session activity tracking with directory support and cooldown logic

This commit is contained in:
Bohdan Triapitsyn
2025-12-25 02:38:38 +02:00
parent b806b01c29
commit 5e6e6a91cf
5 changed files with 439 additions and 115 deletions
+15 -2
View File
@@ -500,12 +500,19 @@ class OpencodeService {
async getSessionStatus(): Promise<
Record<string, { type: "idle" | "busy" | "retry"; attempt?: number; message?: string; next?: number }>
> {
return this.getSessionStatusForDirectory(this.currentDirectory ?? null);
}
async getSessionStatusForDirectory(
directory: string | null | undefined
): Promise<Record<string, { type: "idle" | "busy" | "retry"; attempt?: number; message?: string; next?: number }>> {
try {
const base = this.baseUrl.replace(/\/$/, "");
const url = new URL(`${base}/session/status`);
if (this.currentDirectory && this.currentDirectory.length > 0) {
url.searchParams.set("directory", this.currentDirectory);
const trimmedDirectory = typeof directory === "string" ? directory.trim() : "";
if (trimmedDirectory.length > 0) {
url.searchParams.set("directory", trimmedDirectory);
}
const response = await fetch(url.toString(), {
@@ -533,6 +540,12 @@ class OpencodeService {
}
}
async getGlobalSessionStatus(): Promise<
Record<string, { type: "idle" | "busy" | "retry"; attempt?: number; message?: string; next?: number }>
> {
return this.getSessionStatusForDirectory(null);
}
// Permissions
async respondToPermission(
sessionId: string,