(next: FooterPatch)
| 475 | } |
| 476 | |
| 477 | private patch(next: FooterPatch): void { |
| 478 | if (this.isGone) { |
| 479 | return |
| 480 | } |
| 481 | |
| 482 | const prev = this.state() |
| 483 | if (typeof next.status === "string") { |
| 484 | this.statusVersion++ |
| 485 | } |
| 486 | const state = { |
| 487 | phase: next.phase ?? prev.phase, |
| 488 | status: typeof next.status === "string" ? next.status : prev.status, |
| 489 | queue: typeof next.queue === "number" ? Math.max(0, next.queue) : prev.queue, |
| 490 | model: typeof next.model === "string" ? next.model : prev.model, |
| 491 | duration: typeof next.duration === "string" ? next.duration : prev.duration, |
| 492 | usage: typeof next.usage === "string" ? next.usage : prev.usage, |
| 493 | first: typeof next.first === "boolean" ? next.first : prev.first, |
| 494 | interrupt: |
| 495 | typeof next.interrupt === "number" && Number.isFinite(next.interrupt) |
| 496 | ? Math.max(0, Math.floor(next.interrupt)) |
| 497 | : prev.interrupt, |
| 498 | exit: |
| 499 | typeof next.exit === "number" && Number.isFinite(next.exit) ? Math.max(0, Math.floor(next.exit)) : prev.exit, |
| 500 | } |
| 501 | |
| 502 | if (state.phase === "idle") { |
| 503 | state.interrupt = 0 |
| 504 | } |
| 505 | |
| 506 | this.setState(state) |
| 507 | |
| 508 | if (prev.phase === "running" && state.phase === "idle") { |
| 509 | this.flush() |
| 510 | this.completeScrollback() |
| 511 | } |
| 512 | } |
| 513 | |
| 514 | private completeScrollback(): void { |
| 515 | this.flushing = this.flushing |
no test coverage detected