feat(core): add nx show running-tasks CLI command#34591
Draft
feat(core): add nx show running-tasks CLI command#34591
nx show running-tasks CLI command#34591Conversation
✅ Deploy Preview for nx-dev ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
✅ Deploy Preview for nx-docs ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
Contributor
|
View your CI Pipeline Execution ↗ for commit 64acf17
☁️ Nx Cloud last updated this comment at |
Add message types, server handler, and client methods to track running task state in the daemon's memory. This enables live querying of task status from separate CLI processes.
Reports task status and output to the daemon via existing IPC. Debounces output flushes at 2s intervals. Fire-and-forget to never block task execution. Only active when daemon is enabled.
Queries the daemon for live task status. Returns JSON by default. Use --task <taskId> to get log output for a specific running task.
Return raw objects from handlers instead of JSON.stringify'd strings. The daemon's IPC layer handles serialization — double-serializing caused "[object Object]" parse errors on the client.
Plain string responses fail isJsonMessage() detection on the client,
causing v8 deserialization error. Wrap in { output } object instead.
f898b23 to
64acf17
Compare
Contributor
🐳 We have a release for that!This PR has a release associated with it. You can try it out using this command: npx create-nx-workspace@22.6.0-pr.34591.64acf17 my-workspaceOr just copy this version and use it in your own command: 22.6.0-pr.34591.64acf17
To request a new release for this pull request, mention someone from the Nx team or the |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Current Behavior
AI agents can access running task information through Nx Console's MCP server, which receives updates from the TUI via a socket-based JSON-RPC channel. However, this requires VSCode with Nx Console installed. Terminal-based agents (Claude Code, Cursor terminal, etc.) that don't have access to Nx Console have no way to query running task status — even though the Nx CLI already has this information internally.
Expected Behavior
Expose running task information directly via the Nx CLI with
nx show running-tasks. Since the CLI already tracks this data through its lifecycle system, this provides a more direct path for any agent to query task status without depending on Nx Console or the MCP server.Usage
Output Format
[ { "pid": 12345, "command": "nx run-many -t build,serve", "startTime": "2026-02-24T10:00:00.000Z", "tasks": { "myapp:build": { "status": "success", "continuous": false, "startTime": "2026-02-24T10:00:01.000Z", "endTime": "2026-02-24T10:00:05.000Z" }, "myapp:serve": { "status": "in-progress", "continuous": true, "startTime": "2026-02-24T10:00:05.000Z" } } } ]Architecture
Running
nxprocesses report state to the daemon via a newDaemonReportingLifeCycle. Thenx show running-taskscommand queries the daemon. No files on disk, no new sockets — reuses existing daemon IPC infrastructure.Key implementation details
GET_RUNNING_TASKSprunes processes that are no longer alivenxprocess registers with its own PIDEdge cases handled
NX_DAEMON=false, CI) → lifecycle silently no-opsGET_RUNNING_TASKSprunes dead PIDsnx runprocesses simultaneously → each registers with own PID[]--taskwith non-existent task → clear error message with list of available tasksRelated Issue(s)