Skip to content

Fix user-level tasks.json causing infinite spinner#4659

Merged
hanniavalera merged 4 commits intomainfrom
copilot/fix-tasks-json-issue
Jan 27, 2026
Merged

Fix user-level tasks.json causing infinite spinner#4659
hanniavalera merged 4 commits intomainfrom
copilot/fix-tasks-json-issue

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Jan 22, 2026

This changes visible behavior

User-level tasks defined in ~/.config/Code/User/tasks.json now execute correctly instead of hanging with an infinite spinner.

The following changes are proposed:

  • Add type guard in resolveTask() and resolveInternalTask() to distinguish WorkspaceFolder objects from TaskScope enum values
  • Use TaskScope.Workspace as fallback when scope is not a WorkspaceFolder
  • Add null safety check since typeof null === 'object' in JavaScript

The purpose of this change

Both methods unconditionally cast task.scope to WorkspaceFolder:

// Before
const workspaceFolder: vscode.WorkspaceFolder = task.scope as vscode.WorkspaceFolder;

VSCode's Task API defines task.scope as WorkspaceFolder | TaskScope.Global | TaskScope.Workspace. User-level tasks have scope = TaskScope.Global (numeric value 1), causing the cast to produce invalid state.

// After
const workspaceFolder: vscode.WorkspaceFolder | undefined = 
    (task.scope && typeof task.scope === 'object') ? task.scope as vscode.WorkspaceFolder : undefined;
const resolvedTask = new vscode.Task(definition, workspaceFolder ?? vscode.TaskScope.Workspace, ...);

CustomBuildTaskTerminal already handles undefined workspaceFolder by falling back to the active project.

Original prompt

This section details on the original issue you should resolve

<issue_title>[Bug] User tasks.json doesn't work anymore</issue_title>
<issue_description>### Brief Issue Summary

Tasks defined in ~/.config/Code/User/tasks.json do not work anymore. I only get an infinitely spinning wheel with version 1.21.36. Switching back to 1.20.53, the same task is executed instantly. If I put the task into /.vscode/tasks.json it is also executed instantly (with 1.21.36).

{
    "version": "2.0.0",
    "tasks": [
        {
            "type": "cmake",
            "label": "clean my service",
            "command": "clean",
            "targets": [
                "serviceMain"
            ],
            "problemMatcher": {
                "base": "$gcc",
                "fileLocation": "autoDetect"
            },
            "group": "build",
            "presentation": {
                "panel": "dedicated",
                "clear": true
            }
        }
    ]
}

CMake Tools Diagnostics

{
  "os": "linux",
  "vscodeVersion": "1.103.1",
  "cmtVersion": "1.20.53",
  "configurations": [
    {
      "folder": "/home/torsten.langer/api/services/symbol-maps",
      "cmakeVersion": "3.28.3",
      "configured": true,
      "generator": "Ninja",
      "usesPresets": false,
      "compilers": {
        "C": "/usr/bin/gcc",
        "CXX": "/usr/bin/g++"
      }
    }
  ],
  "cpptoolsIntegration": {
    "isReady": true,
    "hasCodeModel": true,
    "activeBuildType": "Debug",
    "buildTypesSeen": [
      "Debug"
    ],
    "requests": [],
    "responses": [],
    "partialMatches": [],
    "targetCount": 1,
    "executablesCount": 1,
    "librariesCount": 0,
    "targets": [
      {
        "name": "serviceMain",
        "type": "EXECUTABLE"
      }
    ]
  },
  "settings": [
    {
      "communicationMode": "automatic",
      "useCMakePresets": "auto",
      "configureOnOpen": false
    }
  ]
}

Debug Log

Output from CMake/Build:
[proc] Executing command: /usr/bin/cmake --version
[proc] Executing command: /usr/bin/cmake -E capabilities
[kit] Successfully loaded 9 kits from /home/torsten.langer/.local/share/CMakeTools/cmake-tools-kits.json
[variant] Loaded new set of variants
[proc] Executing command: /usr/bin/gcc -v

Output from Extension Host:
2025-08-21 14:53:29.592 [error] TypeError: Cannot read properties of undefined (reading 'path')
    at CustomBuildTaskTerminal.getProject (/home/torsten.langer/.vscode/extensions/ms-vscode.cmake-tools-1.21.36/dist/main.js:87896:80)
    at CustomBuildTaskTerminal.runBuildTask (/home/torsten.langer/.vscode/extensions/ms-vscode.cmake-tools-1.21.36/dist/main.js:87944:34)
    at CustomBuildTaskTerminal.open (/home/torsten.langer/.vscode/extensions/ms-vscode.cmake-tools-1.21.36/dist/main.js:87821:28)
    at _b.startSendingEvents (file:///usr/share/code/resources/app/out/vs/workbench/api/node/extensionHostProcess.js:112:49398)
    at Qy.U (file:///usr/share/code/resources/app/out/vs/workbench/api/node/extensionHostProcess.js:112:53829)
    at Qy.attachPtyToTerminal (file:///usr/share/code/resources/app/out/vs/workbench/api/node/extensionHostProcess.js:112:51873)
    at Yy.$onDidStartTask (file:///usr/share/code/resources/app/out/vs/workbench/api/node/extensionHostProcess.js:121:12554)

Additional Information

No response</issue_description>

Comments on the Issue (you are @copilot in this section)


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI changed the title [WIP] Fix user tasks.json not working in latest version Fix user-level tasks.json causing infinite spinner Jan 22, 2026
Copilot AI requested a review from hanniavalera January 22, 2026 20:29
Copilot AI and others added 2 commits January 26, 2026 23:11
Co-authored-by: hanniavalera <90047725+hanniavalera@users.noreply.github.com>
Co-authored-by: hanniavalera <90047725+hanniavalera@users.noreply.github.com>
@hanniavalera hanniavalera force-pushed the copilot/fix-tasks-json-issue branch from 49d3cb1 to 84f7dbb Compare January 27, 2026 05:11
@hanniavalera
Copy link
Copy Markdown
Contributor

@copilot create a new 1.23 section for the CHANGELOG.md, follow the pattern of the other entries, and place pull request as a bug fix entry

Co-authored-by: hanniavalera <90047725+hanniavalera@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Jan 27, 2026

@copilot create a new 1.23 section for the CHANGELOG.md, follow the pattern of the other entries, and place pull request as a bug fix entry

Done! Added a new 1.23 section to CHANGELOG.md with the bug fix entry. Commit: 036ba03

Co-authored-by: hanniavalera <90047725+hanniavalera@users.noreply.github.com>
@hanniavalera hanniavalera marked this pull request as ready for review January 27, 2026 14:42
@hanniavalera hanniavalera merged commit 9db3902 into main Jan 27, 2026
4 checks passed
@hanniavalera hanniavalera deleted the copilot/fix-tasks-json-issue branch January 27, 2026 15:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] User tasks.json doesn't work anymore

3 participants