feat: enhance session activity tracking with directory support and cooldown logic
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user