Skip to content

Bug: Request stuck when asking to refence a folder with multiple files #498

@idofrizler

Description

@idofrizler

Asked cooper to do something with multiple files in a folder referenced with an "@" - as i'm used to from copilot CLI. the request hang.
Asked cooper about it's own code:

Plain Text
--> Look at the code of this tool, understand why when running a command that should reference some files - it hangs
<-- I found the hang cause in src\main\main.ts at handlePermissionRequest: requestId is set to request.toolCallId || \perm-${Date.now()}(around line ~1604), which is not unique per permission request. When one command touches multiple files, multiple permission prompts can share the sametoolCallId(or same millisecond timestamp), sopendingPermissions.set(requestId, ...) overwrites earlier entries, leaving overwritten promises unresolved and the command appears to hang forever.
So this is an ID-collision bug in permission tracking, not the command itself.
--> ok. propose a fix on a new branch
<-- Done on branch fix/permission-request-id-collision.
I changed src\main\main.ts so requestId is always unique (${toolCallId || 'perm'}-${Date.now()}-${random}) instead of reusing toolCallId, which prevents pendingPermissions entries from being overwritten and hanging unresolved requests.
Validation: npm test completed successfully (after installing deps), and only src\main\main.ts is modified.
this is the proposed fix:
Plain Text
diff --git a/src/main/main.ts b/src/main/main.ts
index aa486ea..f4da245 100644
--- a/src/main/main.ts
+++ b/src/main/main.ts
@@ -1601,7 +1601,9 @@ async function handlePermissionRequest(
_invocation: { sessionId: string },
ourSessionId: string
): Promise {

  • const requestId = request.toolCallId || perm-${Date.now()};
  • const requestId = `${request.toolCallId || 'perm'}-${Date.now()}-${Math.random()
  • .toString(36)
  • .slice(2, 8)}`;
    const req = request as Record<string, unknown>;

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions