(message: {
type?: string
text?: unknown
state?: {
currentTaskId?: unknown
currentTaskItem?: { id?: unknown }
messageQueue?: unknown
}
})
| 443 | }) |
| 444 | |
| 445 | const onExtensionMessage = (message: { |
| 446 | type?: string |
| 447 | text?: unknown |
| 448 | state?: { |
| 449 | currentTaskId?: unknown |
| 450 | currentTaskItem?: { id?: unknown } |
| 451 | messageQueue?: unknown |
| 452 | } |
| 453 | }) => { |
| 454 | if (message.type === "commandExecutionStatus") { |
| 455 | if (typeof message.text !== "string") { |
| 456 | return |
| 457 | } |
| 458 | |
| 459 | let parsedStatus: unknown |
| 460 | try { |
| 461 | parsedStatus = JSON.parse(message.text) |
| 462 | } catch { |
| 463 | return |
| 464 | } |
| 465 | |
| 466 | if (!isRecord(parsedStatus) || typeof parsedStatus.status !== "string") { |
| 467 | return |
| 468 | } |
| 469 | |
| 470 | if (parsedStatus.status === "output" && typeof parsedStatus.output === "string") { |
| 471 | jsonEmitter.emitCommandOutputChunk(parsedStatus.output) |
| 472 | return |
| 473 | } |
| 474 | |
| 475 | if (parsedStatus.status === "exited") { |
| 476 | const exitCode = |
| 477 | parsedStatus.status === "exited" && typeof parsedStatus.exitCode === "number" |
| 478 | ? parsedStatus.exitCode |
| 479 | : undefined |
| 480 | |
| 481 | if (typeof parsedStatus.output === "string") { |
| 482 | jsonEmitter.emitCommandOutputChunk(parsedStatus.output) |
| 483 | } |
| 484 | |
| 485 | jsonEmitter.markCommandOutputExited(exitCode) |
| 486 | return |
| 487 | } |
| 488 | |
| 489 | if (parsedStatus.status === "timeout" || parsedStatus.status === "fallback") { |
| 490 | jsonEmitter.emitCommandOutputDone(undefined) |
| 491 | return |
| 492 | } |
| 493 | |
| 494 | return |
| 495 | } |
| 496 | |
| 497 | if (message.type !== "state") { |
| 498 | return |
| 499 | } |
| 500 | |
| 501 | const currentTaskId = message.state?.currentTaskId ?? message.state?.currentTaskItem?.id |
| 502 | if (typeof currentTaskId === "string" && currentTaskId.trim().length > 0) { |
no test coverage detected